I have some problem on Rpi3. I work for kiosk program. I created python script. If rpi connect to internet, chrome shows page from internet but if there is not internet connection on pi, chrome shows the page I previously saved(page.html).

I created python script for this. I added this python script /home/pi/.config/lxsession/LXDE-pi/autostart file with this way @/usr/bin/python /home/pi/Desktop/check.py. My python script works good if you run manually. Script should control internet connection every ten second and it makes doing the above operations. When reboot rpi, chrome launches page correctly one time after that python script does not doing anything. It does not doing control internet connection or not start new tab. But manually work correct. I tried chmod +x but it did not work. Python script:

#!/usr/bin/env python  
import requests
import os
import webbrowser
import time


def internet_on():
    while True:
            response = requests.get('https://www.google.com/')
            chrome_path='/usr/bin/chromium-browser %s' 
            return True

            chrome_path='/usr/bin/chromium-browser %s'
            return False

def loop():


How can i fix this wrong?

closed as off-topic by Milliways, Ingo, Dmitry Grigoryev, Darth Vader Jan 27 at 14:32

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not appear to be specific to the Raspberry Pi within the scope defined in the help center." – Milliways, Ingo, Dmitry Grigoryev, Darth Vader
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    recursive loops are a recipe for disaster! – Milliways Jan 24 at 10:41

Is the script still alive after it opens Chrome on boot? Do a ps aux to check, my guess it that a webbrowser.Error was raised by either get or open while in the except: block and the script simply failed.

You could add some logging or redirect stdout to a file, if once you run the script with autostart you can't simply see the output anymore.

In addition to this, I'd recommend against calling loop() and internet_on() inside each other, it's better if you make a single method with things happening in that single big while TRUE: loop.

  • Yes I controlled my python script with ps aux | grep script.py. It is alive. – Faruk Jan 24 at 8:54
  • Time to add some logging to understand what's happening, it could be looping in except: forever generating exceptions continuously. – Saltama Jan 24 at 9:00

Not the answer you're looking for? Browse other questions tagged or ask your own question.