core: ensure broker profiling output reaches disk

Profiler hasn't been used much since the hard exit was added.
issue510
David Wilson 6 years ago
parent dc4b27c6bf
commit d4a0b70e15

@ -540,7 +540,7 @@ def enable_profiling():
try: try:
return func(*args) return func(*args)
finally: finally:
profiler.dump_stats('/tmp/mitogen.%d.%s.pstat' % (os.getpid(), name)) profiler.dump_stats('/tmp/mitogen.stats.%d.%s.pstat' % (os.getpid(), name))
profiler.create_stats() profiler.create_stats()
fp = open('/tmp/mitogen.stats.%d.%s.log' % (os.getpid(), name), 'w') fp = open('/tmp/mitogen.stats.%d.%s.log' % (os.getpid(), name), 'w')
try: try:
@ -2798,8 +2798,7 @@ class Broker(object):
(self._waker.receive_side, self._waker.on_receive) (self._waker.receive_side, self._waker.on_receive)
) )
self._thread = threading.Thread( self._thread = threading.Thread(
target=_profile_hook, target=self._broker_main,
args=('broker', self._broker_main),
name='mitogen-broker' name='mitogen-broker'
) )
self._thread.start() self._thread.start()
@ -2932,7 +2931,7 @@ class Broker(object):
'more child processes still connected to ' 'more child processes still connected to '
'our stdout/stderr pipes.', self) 'our stdout/stderr pipes.', self)
def _broker_main(self): def _do_broker_main(self):
""" """
Broker thread main function. Dispatches IO events until Broker thread main function. Dispatches IO events until
:meth:`shutdown` is called. :meth:`shutdown` is called.
@ -2950,6 +2949,9 @@ class Broker(object):
self._exitted = True self._exitted = True
self._broker_exit() self._broker_exit()
def _broker_main(self):
_profile_hook('mitogen-broker', self._do_broker_main)
fire(self, 'exit') fire(self, 'exit')
def shutdown(self): def shutdown(self):

Loading…
Cancel
Save