[CalendarServer-changes] [8384] CalendarServer/branches/users/glyph/parallel-upgrade/twext/internet/ spawnsvc.py
source_changes at macosforge.org
source_changes at macosforge.org
Sat Dec 3 00:37:58 PST 2011
Revision: 8384
http://trac.macosforge.org/projects/calendarserver/changeset/8384
Author: glyph at apple.com
Date: 2011-12-03 00:37:58 -0800 (Sat, 03 Dec 2011)
Log Message:
-----------
more documentation
Modified Paths:
--------------
CalendarServer/branches/users/glyph/parallel-upgrade/twext/internet/spawnsvc.py
Modified: CalendarServer/branches/users/glyph/parallel-upgrade/twext/internet/spawnsvc.py
===================================================================
--- CalendarServer/branches/users/glyph/parallel-upgrade/twext/internet/spawnsvc.py 2011-12-03 08:37:48 UTC (rev 8383)
+++ CalendarServer/branches/users/glyph/parallel-upgrade/twext/internet/spawnsvc.py 2011-12-03 08:37:58 UTC (rev 8384)
@@ -61,33 +61,53 @@
class BridgeTransport(object):
+ """
+ ITransport implementation for the protocol in the parent process running a
+ L{SpawnerService}.
+ """
implements(ITransport, IPushProducer, IConsumer)
def __init__(self, processTransport):
+ """
+ Create this bridge transport connected to an L{IProcessTransport}.
+ """
self.transport = processTransport
def __getattr__(self, name):
+ """
+ Delegate all attribute accesses to the process traansport.
+ """
return getattr(self.transport, name)
def getPeer(self):
+ """
+ Get a fake peer address indicating the subprocess's pid.
+ """
return "Peer:PID:" + str(self.transport.pid)
def getHost(self):
+ """
+ Get a fake host address indicating the subprocess's pid.
+ """
return "Host:PID:" + str(self.transport.pid)
class BridgeProtocol(ProcessProtocol):
"""
- A protocol for a bridge.
+ Process protocol implementation that delivers data to the C{hereProto}
+ associated with an invocation of L{SpawnerService.spawn}.
@ivar service: a L{SpawnerService} that created this L{BridgeProtocol}
@ivar protocol: a reference to the L{IProtocol}.
+
+ @ivar killTimeout: number of seconds after sending SIGINT that this process
+ will send SIGKILL.
"""
def __init__(self, service, protocol, killTimeout=15.0):
@@ -134,7 +154,8 @@
def processEnded(self, reason):
"""
- The process has ended; notify the service that this bridge has stopped.
+ The process has ended; notify the L{SpawnerService} that this bridge
+ has stopped.
"""
if self._killTimeout is not None:
self._killTimeout.cancel()
@@ -165,11 +186,13 @@
def spawn(self, hereProto, thereProto):
"""
- Spawn a subprocess.
+ Spawn a subprocess with a connected pair of protocol objects, one in
+ the current process, one in the subprocess.
@param hereProto: a L{Protocol} instance to listen in this process.
- @param thereProto: a top-level class or function.
+ @param thereProto: a top-level class or function that will be imported
+ and called in the spawned subprocess.
@return: a L{Deferred} that fires when C{hereProto} is ready.
"""
@@ -178,8 +201,8 @@
return
name = qual(thereProto)
self.reactor.spawnProcess(
- BridgeProtocol(self, hereProto),
- sys.executable, [sys.executable, '-m', __name__, name], os.environ
+ BridgeProtocol(self, hereProto), sys.executable,
+ [sys.executable, '-m', __name__, name], os.environ
)
return succeed(hereProto)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20111203/3ed0fa1c/attachment.html>
More information about the calendarserver-changes
mailing list