|
|
@ -29,6 +29,7 @@
|
|
|
|
# !mitogen: minify_safe
|
|
|
|
# !mitogen: minify_safe
|
|
|
|
|
|
|
|
|
|
|
|
import grp
|
|
|
|
import grp
|
|
|
|
|
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
import os.path
|
|
|
|
import os.path
|
|
|
|
import pprint
|
|
|
|
import pprint
|
|
|
@ -41,7 +42,6 @@ import time
|
|
|
|
import mitogen.core
|
|
|
|
import mitogen.core
|
|
|
|
import mitogen.select
|
|
|
|
import mitogen.select
|
|
|
|
from mitogen.core import b
|
|
|
|
from mitogen.core import b
|
|
|
|
from mitogen.core import LOG
|
|
|
|
|
|
|
|
from mitogen.core import str_rpartition
|
|
|
|
from mitogen.core import str_rpartition
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
@ -54,6 +54,8 @@ except NameError:
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LOG = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
DEFAULT_POOL_SIZE = 16
|
|
|
|
DEFAULT_POOL_SIZE = 16
|
|
|
|
_pool = None
|
|
|
|
_pool = None
|
|
|
|
_pool_pid = None
|
|
|
|
_pool_pid = None
|
|
|
@ -501,7 +503,7 @@ class Pool(object):
|
|
|
|
self._py_24_25_compat()
|
|
|
|
self._py_24_25_compat()
|
|
|
|
self._threads = []
|
|
|
|
self._threads = []
|
|
|
|
for x in range(size):
|
|
|
|
for x in range(size):
|
|
|
|
name = 'mitogen.service.Pool.%x.worker-%d' % (id(self), x,)
|
|
|
|
name = 'mitogen.Pool.%04x.%d' % (id(self) & 0xffff, x,)
|
|
|
|
thread = threading.Thread(
|
|
|
|
thread = threading.Thread(
|
|
|
|
name=name,
|
|
|
|
name=name,
|
|
|
|
target=mitogen.core._profile_hook,
|
|
|
|
target=mitogen.core._profile_hook,
|
|
|
@ -608,9 +610,11 @@ class Pool(object):
|
|
|
|
while not self.closed:
|
|
|
|
while not self.closed:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
event = self._select.get_event()
|
|
|
|
event = self._select.get_event()
|
|
|
|
except (mitogen.core.ChannelError, mitogen.core.LatchError):
|
|
|
|
except mitogen.core.LatchError:
|
|
|
|
e = sys.exc_info()[1]
|
|
|
|
LOG.debug('%r: graceful exit', self)
|
|
|
|
LOG.debug('%r: channel or latch closed, exitting: %s', self, e)
|
|
|
|
return
|
|
|
|
|
|
|
|
except mitogen.core.ChannelError:
|
|
|
|
|
|
|
|
LOG.debug('%r: exitting: %s', self, sys.exc_info()[1])
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
func = self._func_by_source[event.source]
|
|
|
|
func = self._func_by_source[event.source]
|
|
|
@ -629,8 +633,8 @@ class Pool(object):
|
|
|
|
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
def __repr__(self):
|
|
|
|
th = threading.currentThread()
|
|
|
|
th = threading.currentThread()
|
|
|
|
return 'mitogen.service.Pool(%#x, size=%d, th=%r)' % (
|
|
|
|
return 'Pool(%04x, size=%d, th=%r)' % (
|
|
|
|
id(self),
|
|
|
|
id(self) & 0xffff,
|
|
|
|
len(self._threads),
|
|
|
|
len(self._threads),
|
|
|
|
th.getName(),
|
|
|
|
th.getName(),
|
|
|
|
)
|
|
|
|
)
|
|
|
|