Bugfix: Check fd still has a handler object, in case it has been destroyed in the...
[bitcoin:eloipool.git] / interactivemode.py
1 def _RunCLI():
2         import code, sys, threading
3         try:
4                 raise None
5         except:
6                 namespace = sys.exc_info()[2].tb_frame.f_back.f_back.f_globals
7         
8         namespace['sys'] = sys
9         
10         def CLI():
11                 while True:
12                         code.interact(local=namespace, banner='')
13                         print("Not exiting implicitly. Use sys.exit() if you really want to.")
14                         dt = ndt = 0
15                         for thread in threading.enumerate():
16                                 if thread.daemon:
17                                         dt += 1
18                                 else:
19                                         ndt += 1
20                         print("(%d threads: %d primary, %d daemon)" % (dt + ndt, ndt, dt))
21         threading.Timer(0, CLI).start()
22
23 _RunCLI()