issue #155: pass reference to existing Router into Stream constructor

This is a hacky layering violation, but it seems the simplest approach
for now: fork needs access to Router, in order to recover the existing
Importer instance.
pull/167/head
David Wilson 6 years ago
parent 21ef540cd8
commit 878e7a0902

@ -310,7 +310,8 @@ class Stream(mitogen.core.Stream):
self.routes = set([self.remote_id]) self.routes = set([self.remote_id])
def construct(self, remote_name=None, python_path=None, debug=False, def construct(self, remote_name=None, python_path=None, debug=False,
connect_timeout=None, profiling=False, **kwargs): connect_timeout=None, profiling=False,
old_router=None, **kwargs):
"""Get the named context running on the local machine, creating it if """Get the named context running on the local machine, creating it if
it does not exist.""" it does not exist."""
super(Stream, self).construct(**kwargs) super(Stream, self).construct(**kwargs)
@ -614,7 +615,7 @@ class Router(mitogen.core.Router):
def _connect(self, klass, name=None, **kwargs): def _connect(self, klass, name=None, **kwargs):
context_id = self.allocate_id() context_id = self.allocate_id()
context = self.context_class(self, context_id) context = self.context_class(self, context_id)
stream = klass(self, context_id, **kwargs) stream = klass(self, context_id, old_router=self, **kwargs)
if name is not None: if name is not None:
stream.name = name stream.name = name
stream.connect() stream.connect()

Loading…
Cancel
Save