issue #155: fork: nop out get_boot_command, it's become quite expensive

-16% reduction in fork cost.
pull/178/head
David Wilson 6 years ago
parent e7c98e3bda
commit 52d980ad58

@ -70,7 +70,7 @@ class Stream(mitogen.parent.Stream):
name_prefix = 'fork'
def create_child(self, *_args):
def start_child(self):
parentfp, childfp = mitogen.parent.create_socketpair()
self.pid = os.fork()
if self.pid:

@ -442,9 +442,12 @@ class Stream(mitogen.core.Stream):
create_child = staticmethod(create_child)
name_prefix = 'local'
def start_child(self):
return self.create_child(*self.get_boot_command())
def connect(self):
LOG.debug('%r.connect()', self)
self.pid, fd = self.create_child(*self.get_boot_command())
self.pid, fd = self.start_child()
self.name = '%s.%s' % (self.name_prefix, self.pid)
self.receive_side = mitogen.core.Side(self, fd)
self.transmit_side = mitogen.core.Side(self, os.dup(fd))

Loading…
Cancel
Save