my problem seems simple:
i have a pythonscript function to read a php file via urlib2 periodically every 3 seconds (i set this up with the timer-plugin). sometimes it takes longer for various reasons to read. it still finishes after sometime and starts again - if it takes some time longer again for some reason it starts clocking up to the point where my internetconnection is theoretically working but i have to factory reset the modem to be able to surf in the internet... something with the dns-lookup seems going wrong at that point for all internetsites routet through the modem. i am not kidding... also from another device. I also cannot normally stop eventghost at that point and have to kill it via taskmanager.
easiest way would be to tell the function to stop if it takes longer than 2.5 seconds so the new cycle can start freshly.... so i kind of need to kill the thread and not just exit()?
i could just tell my script to use the timer to set up a new timer that triggers an action that ends the current one? how would that work? is it even possible to end a thread from outside? any other inputs? i put the code below:
"is_connected" is the function that looks if there is internet present.
todomi = urllib2.urlopen("https://data.josefwagner.net/intvid_tra ... iggers.php").read()
is the one that causes the mess...
Code: Select all
import urllib2 import string def triggerlookup(): print "triggerlookup started" eg.plugins.Timer.TimerAction(u'checktrigger', 0, 0, 3.0, u'check for triggers', False, True, 1, u'00:00:00') try: print "try" todomi = urllib2.urlopen("https://data.josefwagner.net/intvid_transcreen/php-functions/active_triggers.php").read() print "trytrue" except urllib2.HTTPError, e: print "http error" raise SystemExit() except urllib2.URLError, e: print "url error" raise SystemExit() except Exception: print "exception_error_found in triggerlookup" raise SystemExit() if todomi: eg.TriggerEvent(u"command_from_dominique__"+str(todomi)) print "triggerfiring" raise SystemExit() return True else: print "no trigger found" raise SystemExit() return False import socket def is_connected(): try: # connect to the host -- tells us if the host is actually # reachable socket.create_connection(("www.google.com", 80)) print "internet on" triggerlookup() except OSError: print "internet off" raise SystemExit() except Exception: print "internetcheck exception_error_found resetting timer to slower" eg.plugins.Timer.TimerAction(u'checktrigger', 0, 0, 10.0, u'check for triggers', False, True, 1, u'00:00:00') raise SystemExit() is_connected() raise SystemExit