[CalendarServer-changes] [8379] 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:06 PST 2011
Revision: 8379
http://trac.macosforge.org/projects/calendarserver/changeset/8379
Author: glyph at apple.com
Date: 2011-12-03 00:37:06 -0800 (Sat, 03 Dec 2011)
Log Message:
-----------
minor error handling / fixes
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:36:57 UTC (rev 8378)
+++ CalendarServer/branches/users/glyph/parallel-upgrade/twext/internet/spawnsvc.py 2011-12-03 08:37:06 UTC (rev 8379)
@@ -23,9 +23,11 @@
from twisted.python.reflect import namedAny
from twisted.internet.stdio import StandardIO
+from twisted.internet.error import ReactorNotRunning
if __name__ == '__main__':
+ sys.stdout = sys.stderr
there = sys.argv[1]
protocolClass = namedAny(there)
proto = protocolClass()
@@ -34,7 +36,10 @@
"""
Stop the process if stdin is closed.
"""
- reactor.stop()
+ try:
+ reactor.stop()
+ except ReactorNotRunning:
+ pass
return origLost(reason)
proto.connectionLost = goodbye
StandardIO(proto)
@@ -106,6 +111,12 @@
self.protocol.dataReceived(data)
+ def errReceived(self, data):
+ """
+ Some standard error was received from the subprocess. (TODO: logging?)
+ """
+
+
_killTimeout = None
def eventuallyStop(self):
"""
@@ -149,6 +160,7 @@
self.reactor = reactor
self.pendingSpawns = []
self.bridges = []
+ self._stopAllDeferred = None
def spawn(self, hereProto, thereProto):
@@ -159,7 +171,7 @@
@param thereProto: a top-level class or function.
- @return: hereProto
+ @return: a L{Deferred} that fires when C{hereProto} is ready.
"""
if not self.running:
self.pendingSpawns.append((hereProto, thereProto))
@@ -169,7 +181,7 @@
BridgeProtocol(self, hereProto),
sys.executable, [sys.executable, '-m', __name__, name], os.environ
)
- return hereProto
+ return succeed(hereProto)
def startService(self):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20111203/f0041357/attachment.html>
More information about the calendarserver-changes
mailing list