Created
May 5, 2014 16:32
-
-
Save muzhig/3c84cc41f0c131760ac5 to your computer and use it in GitHub Desktop.
twisted process fork
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@classmethod | |
def start(cls, port=8080, extra_workers=0): | |
reactor.listenTCP(port, server.Site(cls())) | |
for i in range(extra_workers): | |
pid = os.fork() | |
if pid == 0: | |
# Proceed immediately onward in the children. | |
# The parent will continue the for loop. | |
break | |
else: | |
print 'Spawned child:', pid | |
else: | |
print 'Parent', os.getpid() | |
reactor.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment