From 5d67ce77469af97a8d9144ba9e44fa4e83bb0e1c Mon Sep 17 00:00:00 2001 From: David Wilson Date: Thu, 26 Jul 2018 18:39:38 -0700 Subject: [PATCH] service: service pool threads should respect _profile_hook. --- docs/changelog.rst | 3 +++ mitogen/service.py | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index fae40798..39e43ccf 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -86,6 +86,9 @@ Core Library * Debug logs containing command lines are printed with the minimal quoting and escaping required. +* When :func:`mitogen.core.enable_profiling` is active, :mod:`mitogen.service` + threads are run under the profiling hook just like other threads. + Thanks! ~~~~~~~ diff --git a/mitogen/service.py b/mitogen/service.py index 8af02d0e..923ec04a 100644 --- a/mitogen/service.py +++ b/mitogen/service.py @@ -444,9 +444,11 @@ class Pool(object): self.add(service) self._threads = [] for x in range(size): + name = 'mitogen.service.Pool.%x.worker-%d' % (id(self), x,) thread = threading.Thread( - name='mitogen.service.Pool.%x.worker-%d' % (id(self), x,), - target=self._worker_main, + name=name, + target=mitogen.core._profile_hook, + args=(name, self._worker_main), ) thread.start() self._threads.append(thread)