fakessh: fix non-master context ID allocation.

This commit is contained in:
David Wilson 2017-09-20 20:00:29 +05:30
parent bd8001d481
commit 8d4005c264
1 changed files with 7 additions and 3 deletions

View File

@ -315,8 +315,9 @@ def _fakessh_main(mitogen_, dest_context_id):
# Public API. # Public API.
# #
@mitogen.core.takes_econtext
@mitogen.core.takes_router @mitogen.core.takes_router
def run(dest, router, args, deadline=None): def run(dest, router, args, deadline=None, econtext=None):
""" """
Run the command specified by the argument vector `args` such that ``PATH`` Run the command specified by the argument vector `args` such that ``PATH``
searches for SSH by the command will cause its attempt to use SSH to searches for SSH by the command will cause its attempt to use SSH to
@ -335,9 +336,12 @@ def run(dest, router, args, deadline=None):
:returns: :returns:
Exit status of the child process. Exit status of the child process.
""" """
context_id = router.context_id_counter.next() if econtext is not None:
mitogen.master.upgrade_router(econtext)
context_id = router.allocate_id()
fakessh = mitogen.master.Context(router, context_id) fakessh = mitogen.master.Context(router, context_id)
fakessh.name = 'fakessh' fakessh.name = 'fakessh.%d' % (context_id,)
sock1, sock2 = socket.socketpair() sock1, sock2 = socket.socketpair()
mitogen.core.set_cloexec(sock1.fileno()) mitogen.core.set_cloexec(sock1.fileno())