Remove final vestiges of context.key.

pull/35/head
David Wilson 8 years ago
parent f186b4c9d8
commit df1dc41d4f

@ -87,9 +87,8 @@ The script sent is simply the source code for :py:mod:`mitogen.core`, with a
single line suffixed to trigger execution of the single line suffixed to trigger execution of the
:py:meth:`mitogen.core.ExternalContext.main` function. The encoded arguments :py:meth:`mitogen.core.ExternalContext.main` function. The encoded arguments
to the main function include some additional details, such as the logging package to the main function include some additional details, such as the logging package
level that was active in the parent process, and a random secret key that may level that was active in the parent process, and whether debugging or profiling
later be used to generate HMAC signatures over the data frames that will be are enabled.
exchanged after bootstrap.
After the script source code is prepared, it is passed through After the script source code is prepared, it is passed through
:py:func:`mitogen.master.minimize_source` to strip it of docstrings and :py:func:`mitogen.master.minimize_source` to strip it of docstrings and

@ -8,7 +8,6 @@ import imp
import itertools import itertools
import logging import logging
import os import os
import random
import select import select
import socket import socket
import struct import struct
@ -589,10 +588,9 @@ class Stream(BasicStream):
_input_buf = '' _input_buf = ''
_output_buf = '' _output_buf = ''
def __init__(self, router, remote_id, key, **kwargs): def __init__(self, router, remote_id, **kwargs):
self._router = router self._router = router
self.remote_id = remote_id self.remote_id = remote_id
self.key = key
self.name = 'default' self.name = 'default'
self.construct(**kwargs) self.construct(**kwargs)
@ -695,11 +693,10 @@ class Context(object):
""" """
remote_name = None remote_name = None
def __init__(self, router, context_id, name=None, key=None): def __init__(self, router, context_id, name=None):
self.router = router self.router = router
self.context_id = context_id self.context_id = context_id
self.name = name self.name = name
self.key = key or ('%016x' % random.getrandbits(128))
def __reduce__(self): def __reduce__(self):
return _unpickle_context, (self.context_id, self.name) return _unpickle_context, (self.context_id, self.name)
@ -1099,7 +1096,7 @@ class ExternalContext(object):
def _on_broker_shutdown(self): def _on_broker_shutdown(self):
self.channel.close() self.channel.close()
def _setup_master(self, profiling, parent_id, context_id, key, in_fd, out_fd): def _setup_master(self, profiling, parent_id, context_id, in_fd, out_fd):
if profiling: if profiling:
enable_profiling() enable_profiling()
self.broker = Broker() self.broker = Broker()
@ -1111,7 +1108,7 @@ class ExternalContext(object):
self.parent = Context(self.router, parent_id, 'parent') self.parent = Context(self.router, parent_id, 'parent')
self.channel = Receiver(self.router, CALL_FUNCTION) self.channel = Receiver(self.router, CALL_FUNCTION)
self.stream = Stream(self.router, parent_id, key) self.stream = Stream(self.router, parent_id)
self.stream.name = 'parent' self.stream.name = 'parent'
self.stream.accept(in_fd, out_fd) self.stream.accept(in_fd, out_fd)
self.stream.receive_side.keep_alive = False self.stream.receive_side.keep_alive = False
@ -1198,9 +1195,9 @@ class ExternalContext(object):
Message.pickled(e, dst_id=msg.src_id, handle=msg.reply_to) Message.pickled(e, dst_id=msg.src_id, handle=msg.reply_to)
) )
def main(self, parent_id, context_id, key, debug, profiling, log_level, def main(self, parent_id, context_id, debug, profiling, log_level,
in_fd=100, out_fd=1, core_src_fd=101, setup_stdio=True): in_fd=100, out_fd=1, core_src_fd=101, setup_stdio=True):
self._setup_master(profiling, parent_id, context_id, key, in_fd, out_fd) self._setup_master(profiling, parent_id, context_id, in_fd, out_fd)
try: try:
try: try:
self._setup_logging(debug, log_level) self._setup_logging(debug, log_level)

@ -361,7 +361,7 @@ def run(dest, router, args, deadline=None, econtext=None):
sock1, sock2 = socket.socketpair() sock1, sock2 = socket.socketpair()
mitogen.core.set_cloexec(sock1.fileno()) mitogen.core.set_cloexec(sock1.fileno())
stream = mitogen.core.Stream(router, context_id, fakessh.key) stream = mitogen.core.Stream(router, context_id)
stream.name = 'fakessh' stream.name = 'fakessh'
stream.accept(sock1.fileno(), sock1.fileno()) stream.accept(sock1.fileno(), sock1.fileno())
router.register(fakessh, stream) router.register(fakessh, stream)
@ -380,7 +380,6 @@ def run(dest, router, args, deadline=None, econtext=None):
fp.write('ExternalContext().main%r\n' % (( fp.write('ExternalContext().main%r\n' % ((
mitogen.context_id, # parent_id mitogen.context_id, # parent_id
context_id, # context_id context_id, # context_id
fakessh.key, # key
router.debug, # debug router.debug, # debug
router.profiling, # profiling router.profiling, # profiling
logging.getLogger().level, # log_level logging.getLogger().level, # log_level

@ -596,7 +596,6 @@ class Stream(mitogen.core.Stream):
source += '\nExternalContext().main%r\n' % (( source += '\nExternalContext().main%r\n' % ((
mitogen.context_id, # parent_id mitogen.context_id, # parent_id
self.remote_id, # context_id self.remote_id, # context_id
self.key,
self.debug, self.debug,
self.profiling, self.profiling,
LOG.level or logging.getLogger().level or logging.INFO, LOG.level or logging.getLogger().level or logging.INFO,
@ -800,7 +799,7 @@ class Router(mitogen.core.Router):
def _connect(self, context_id, klass, name=None, **kwargs): def _connect(self, context_id, klass, name=None, **kwargs):
context = Context(self, context_id) context = Context(self, context_id)
stream = klass(self, context.context_id, context.key, **kwargs) stream = klass(self, context.context_id, **kwargs)
if name is not None: if name is not None:
stream.name = name stream.name = name
stream.connect() stream.connect()

Loading…
Cancel
Save