Package gozerbot :: Module exit
[hide private]
[frames] | no frames]

Source Code for Module gozerbot.exit

 1  # gozerbot/exit.py 
 2  # 
 3  # 
 4   
 5  """ this is where the datadir lives """ 
 6   
 7  __copyright__ = 'this file is in the public domain' 
 8   
 9  import os 
10   
11  try: 
12      from gozerbot.generic import rlog 
13      from gozerbot.eventhandler import mainhandler 
14      from gozerbot.plugins import plugins 
15      from gozerbot.fleet import fleet 
16      from gozerbot.persist import saving 
17      from gozerbot.runner import runners_stop 
18      import atexit, os, time 
19  except Exception, ex: 
20      print str(ex) 
21      os._exit(1) 
22   
23 -def globalshutdown():
24 """ shutdown the bot """ 25 rlog(10, 'GOZERBOT', 'SHUTTING DOWN') 26 #mainhandler.stop() 27 runners_stop() 28 rlog(10, 'gozerbot', 'shutting down plugins') 29 plugins.exit() 30 while saving: 31 rlog(10, 'gozerbot', 'still saving') 32 time.sleep(2) 33 rlog(10, 'gozerbot', 'shutting down fleet') 34 fleet.exitall() 35 rlog(10, 'GOZERBOT', 'done') 36 os._exit(0)
37 38 atexit.register(globalshutdown) 39