Commit adf52744 authored by David Wilson's avatar David Wilson

issue #155: parent: split out make_call_msg().

parent d23a6174
......@@ -253,6 +253,19 @@ def upgrade_router(econtext):
)
def make_call_msg(fn, *args, **kwargs):
if isinstance(fn, types.MethodType) and \
isinstance(fn.im_self, (type, types.ClassType)):
klass = fn.im_self.__name__
else:
klass = None
return mitogen.core.Message.pickled(
(fn.__module__, klass, fn.__name__, args, kwargs),
handle=mitogen.core.CALL_FUNCTION,
)
def _docker_method():
import mitogen.docker
return mitogen.docker.Stream
......@@ -496,19 +509,7 @@ class Context(mitogen.core.Context):
def call_async(self, fn, *args, **kwargs):
LOG.debug('%r.call_async(%r, *%r, **%r)',
self, fn, args, kwargs)
if isinstance(fn, types.MethodType) and \
isinstance(fn.im_self, (type, types.ClassType)):
klass = fn.im_self.__name__
else:
klass = None
return self.send_async(
mitogen.core.Message.pickled(
(fn.__module__, klass, fn.__name__, args, kwargs),
handle=mitogen.core.CALL_FUNCTION,
)
)
return self.send_async(make_call_msg(fn, *args, **kwargs))
def call(self, fn, *args, **kwargs):
receiver = self.call_async(fn, *args, **kwargs)
......
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