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):
for fullname in self.ALWAYS_PRELOAD:
self.router.responder.forward_module(context, fullname)
self.router.responder.forward_modules(context, self.ALWAYS_PRELOAD)
_candidate_temp_dirs = None

@ -681,8 +681,7 @@ class ModuleResponder(object):
)
)
def _forward_module(self, context, fullname):
IOLOG.debug('%r._forward_module(%r, %r)', self, context, fullname)
def _forward_one_module(self, context, fullname):
path = []
while fullname:
path.append(fullname)
@ -693,8 +692,13 @@ class ModuleResponder(object):
self._send_module_and_related(stream, fullname)
self._send_forward_module(stream, context, fullname)
def forward_module(self, context, fullname):
self._router.broker.defer(self._forward_module, context, fullname)
def _forward_modules(self, context, fullnames):
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):

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

Loading…
Cancel
Save