Commit c31a177e authored by David Wilson's avatar David Wilson

issue #155: parent: split get_main_kwargs() from get_preamble()

parent b5136520
...@@ -385,12 +385,10 @@ class Stream(mitogen.core.Stream): ...@@ -385,12 +385,10 @@ class Stream(mitogen.core.Stream):
'exec(_(_("%s".encode(),"base64"),"zip"))' % (encoded,) 'exec(_(_("%s".encode(),"base64"),"zip"))' % (encoded,)
] ]
def get_preamble(self): def get_main_kwargs(self):
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 {
source = inspect.getsource(mitogen.core)
source += '\nExternalContext().main(**%r)\n' % ({
'parent_ids': parent_ids, 'parent_ids': parent_ids,
'context_id': self.remote_id, 'context_id': self.remote_id,
'debug': self.debug, 'debug': self.debug,
...@@ -398,8 +396,13 @@ class Stream(mitogen.core.Stream): ...@@ -398,8 +396,13 @@ 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(),
},) }
def get_preamble(self):
source = inspect.getsource(mitogen.core)
source += '\nExternalContext().main(**%r)\n' % (
self.get_main_kwargs(),
)
return zlib.compress(minimize_source(source), 9) return zlib.compress(minimize_source(source), 9)
create_child = staticmethod(create_child) create_child = staticmethod(create_child)
......
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