fix logic so threads do an orderly shutdown
basically the issue was that the main loop received the SIGINT and therefore broke out before reaching the parts of the code that care about bringing down the child threads. therefore there's now a finish() method that needs to be called after stop(). because sqlite dbs insists to be used from the thread that created the object, the DB cleanup operation are done from the thread that controls it. for standalone operation, in order to keep the main thread alive, an additional run() method is used. this is not necessary when used via ppf.py.
This commit is contained in:
10
ppf.py
10
ppf.py
@@ -176,7 +176,7 @@ if __name__ == '__main__':
|
||||
# start proxy watcher
|
||||
if config.watchd_threads > 0:
|
||||
watcherd = proxywatchd.Proxywatchd()
|
||||
watcherd.run_background()
|
||||
watcherd.start()
|
||||
else:
|
||||
watcherd = None
|
||||
|
||||
@@ -191,11 +191,9 @@ if __name__ == '__main__':
|
||||
else: time.sleep(10)
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print "XXXXXX"
|
||||
if watcherd: watcherd.stop()
|
||||
if watcherd:
|
||||
watcherd.stop()
|
||||
watcherd.finish()
|
||||
break
|
||||
|
||||
print '\r',
|
||||
|
||||
# stop things
|
||||
#if watcherd: watcherd.stop()
|
||||
|
||||
Reference in New Issue
Block a user