master: allow batching context switches for forward_modules()

-7 switches per task.
pull/372/head
David Wilson 6 years ago
parent 86942b6bf9
commit 32751cd356

@ -269,8 +269,7 @@ class ContextService(mitogen.service.Service):
) )
def _send_module_forwards(self, context): def _send_module_forwards(self, context):
for fullname in self.ALWAYS_PRELOAD: self.router.responder.forward_modules(context, self.ALWAYS_PRELOAD)
self.router.responder.forward_module(context, fullname)
_candidate_temp_dirs = None _candidate_temp_dirs = None

@ -681,8 +681,7 @@ class ModuleResponder(object):
) )
) )
def _forward_module(self, context, fullname): def _forward_one_module(self, context, fullname):
IOLOG.debug('%r._forward_module(%r, %r)', self, context, fullname)
path = [] path = []
while fullname: while fullname:
path.append(fullname) path.append(fullname)
@ -693,8 +692,13 @@ class ModuleResponder(object):
self._send_module_and_related(stream, fullname) self._send_module_and_related(stream, fullname)
self._send_forward_module(stream, context, fullname) self._send_forward_module(stream, context, fullname)
def forward_module(self, context, fullname): def _forward_modules(self, context, fullnames):
self._router.broker.defer(self._forward_module, context, fullname) IOLOG.debug('%r._forward_modules(%r, %r)', self, context, fullnames)
for fullname in fullnames:
self._forward_one_module(context, fullname)
def forward_modules(self, context, fullnames):
self._router.broker.defer(self._forward_modules, context, fullnames)
class Broker(mitogen.core.Broker): class Broker(mitogen.core.Broker):

@ -636,8 +636,7 @@ class PushFileService(Service):
""" """
for path in paths: for path in paths:
self.propagate_to(context, path) self.propagate_to(context, path)
for fullname in modules: self.router.responder.forward_modules(context, modules)
self.router.responder.forward_module(context, fullname)
@expose(policy=AllowParents()) @expose(policy=AllowParents())
@arg_spec({ @arg_spec({

Loading…
Cancel
Save