Commit a0d9d342 authored by David Wilson's avatar David Wilson

core: fix profiling

* SIGTERM safety net prevents profiler from writing results, so disable
  it when profiling is active.
* fix warning corrupting stream when profiling=True
parent b158259c
......@@ -43,8 +43,13 @@ import sys
import threading
import time
import traceback
import warnings
import zlib
# TODO: usage of 'import' after setting __name__, but before fixing up
# sys.modules generates a warning. This happens when profiling = True.
warnings.filterwarnings('ignore',
"Parent module 'mitogen' not found while handling absolute import")
LOG = logging.getLogger('mitogen')
IOLOG = logging.getLogger('mitogen.io')
......@@ -1129,6 +1134,7 @@ class ExternalContext(object):
self.channel.close()
def _on_broker_exit(self):
if not self.profiling:
os.kill(os.getpid(), signal.SIGTERM)
def _on_shutdown_msg(self, msg):
......@@ -1139,6 +1145,7 @@ class ExternalContext(object):
self.broker.shutdown()
def _setup_master(self, profiling, parent_id, context_id, in_fd, out_fd):
self.profiling = profiling
if profiling:
enable_profiling()
self.broker = Broker()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment