Modify atexit trigger to work better

This commit is contained in:
Joshua Boniface 2018-06-16 22:26:19 -04:00
parent 4881a93758
commit 90801858f4
1 changed files with 5 additions and 9 deletions

14
pvcd.py
View File

@ -113,16 +113,12 @@ def zk_listener(state):
zk.add_listener(zk_listener) zk.add_listener(zk_listener)
@atexit.register
def cleanup(): def cleanup():
try: update_timer.shutdown()
update_timer.shutdown() zk.set('/nodes/{}/daemonstate'.format(myhostname), 'stop'.encode('ascii'))
zk.set('/nodes/{}/daemonstate'.format(myhostname), 'stop'.encode('ascii')) zk.stop()
zk.stop() zk.close()
zk.close()
except:
pass
atexit.register(cleanup)
# Gather useful data about our host for staticdata # Gather useful data about our host for staticdata
# Static data format: 'cpu_count', 'arch', 'os', 'kernel' # Static data format: 'cpu_count', 'arch', 'os', 'kernel'