Commit 7f4b89b7 authored by David Wilson's avatar David Wilson

issue #156: log worker thread crashes in mitogen.pool

parent 6e368d37
......@@ -100,7 +100,7 @@ class Pool(object):
self._threads = []
for x in xrange(size):
thread = threading.Thread(
name='mitogen.service.Pool.worker-%d' % (x,),
name='mitogen.service.Pool.%x.worker-%d' % (id(self), x,),
target=self._worker_main,
)
thread.start()
......@@ -111,7 +111,7 @@ class Pool(object):
for th in self._threads:
th.join()
def _worker_main(self):
def _worker_run(self):
while True:
try:
msg = self._select.get()
......@@ -126,6 +126,17 @@ class Pool(object):
except Exception:
LOG.exception('While handling %r using %r', msg, service)
def _worker_main(self):
try:
self._worker_run()
except Exception:
th = threading.currentThread()
LOG.exception('%r: worker %r crashed', self, th.name)
raise
def __repr__(self):
return 'mitogen.service.Pool(%#x, size=%d)' % (id(self), self.size)
def call(context, handle, obj):
msg = mitogen.core.Message.pickled(obj, handle=handle)
......
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