|
|
|
@ -337,6 +337,10 @@ class Stream(mitogen.core.Stream):
|
|
|
|
#: Set to the child's PID by connect().
|
|
|
|
#: Set to the child's PID by connect().
|
|
|
|
pid = None
|
|
|
|
pid = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#: Passed via Router wrapper methods, must eventually be passed to
|
|
|
|
|
|
|
|
#: ExternalContext.main().
|
|
|
|
|
|
|
|
max_message_size = None
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(Stream, self).__init__(*args, **kwargs)
|
|
|
|
super(Stream, self).__init__(*args, **kwargs)
|
|
|
|
self.sent_modules = set(['mitogen', 'mitogen.core'])
|
|
|
|
self.sent_modules = set(['mitogen', 'mitogen.core'])
|
|
|
|
@ -344,12 +348,13 @@ class Stream(mitogen.core.Stream):
|
|
|
|
#: during disconnection.
|
|
|
|
#: during disconnection.
|
|
|
|
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, max_message_size, remote_name=None, python_path=None,
|
|
|
|
connect_timeout=None, profiling=False,
|
|
|
|
debug=False, connect_timeout=None, profiling=False,
|
|
|
|
old_router=None, **kwargs):
|
|
|
|
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)
|
|
|
|
|
|
|
|
self.max_message_size = max_message_size
|
|
|
|
if python_path:
|
|
|
|
if python_path:
|
|
|
|
self.python_path = python_path
|
|
|
|
self.python_path = python_path
|
|
|
|
if sys.platform == 'darwin' and self.python_path == '/usr/bin/python':
|
|
|
|
if sys.platform == 'darwin' and self.python_path == '/usr/bin/python':
|
|
|
|
@ -367,6 +372,7 @@ class Stream(mitogen.core.Stream):
|
|
|
|
self.remote_name = remote_name
|
|
|
|
self.remote_name = remote_name
|
|
|
|
self.debug = debug
|
|
|
|
self.debug = debug
|
|
|
|
self.profiling = profiling
|
|
|
|
self.profiling = profiling
|
|
|
|
|
|
|
|
self.max_message_size = max_message_size
|
|
|
|
self.connect_deadline = time.time() + self.connect_timeout
|
|
|
|
self.connect_deadline = time.time() + self.connect_timeout
|
|
|
|
|
|
|
|
|
|
|
|
def on_shutdown(self, broker):
|
|
|
|
def on_shutdown(self, broker):
|
|
|
|
@ -441,6 +447,7 @@ class Stream(mitogen.core.Stream):
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
def get_main_kwargs(self):
|
|
|
|
def get_main_kwargs(self):
|
|
|
|
|
|
|
|
assert self.max_message_size is not None
|
|
|
|
parent_ids = mitogen.parent_ids[:]
|
|
|
|
parent_ids = mitogen.parent_ids[:]
|
|
|
|
parent_ids.insert(0, mitogen.context_id)
|
|
|
|
parent_ids.insert(0, mitogen.context_id)
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
@ -451,6 +458,7 @@ class Stream(mitogen.core.Stream):
|
|
|
|
'log_level': get_log_level(),
|
|
|
|
'log_level': get_log_level(),
|
|
|
|
'whitelist': self._router.get_module_whitelist(),
|
|
|
|
'whitelist': self._router.get_module_whitelist(),
|
|
|
|
'blacklist': self._router.get_module_blacklist(),
|
|
|
|
'blacklist': self._router.get_module_blacklist(),
|
|
|
|
|
|
|
|
'max_message_size': self.max_message_size,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
def get_preamble(self):
|
|
|
|
def get_preamble(self):
|
|
|
|
@ -703,7 +711,9 @@ 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, old_router=self, **kwargs)
|
|
|
|
kwargs['old_router'] = self
|
|
|
|
|
|
|
|
kwargs['max_message_size'] = self.max_message_size
|
|
|
|
|
|
|
|
stream = klass(self, context_id, **kwargs)
|
|
|
|
if name is not None:
|
|
|
|
if name is not None:
|
|
|
|
stream.name = name
|
|
|
|
stream.name = name
|
|
|
|
stream.connect()
|
|
|
|
stream.connect()
|
|
|
|
|