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)
@atexit.register
def cleanup():
try:
update_timer.shutdown()
zk.set('/nodes/{}/daemonstate'.format(myhostname), 'stop'.encode('ascii'))
zk.stop()
zk.close()
except:
pass
atexit.register(cleanup)
update_timer.shutdown()
zk.set('/nodes/{}/daemonstate'.format(myhostname), 'stop'.encode('ascii'))
zk.stop()
zk.close()
# Gather useful data about our host for staticdata
# Static data format: 'cpu_count', 'arch', 'os', 'kernel'