Created
January 20, 2014 08:24
-
-
Save sp3c73r2038/8516721 to your computer and use it in GitHub Desktop.
master/worker prefork process model.
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
#!/usr/bin/env python | |
from __future__ import unicode_literals, print_function | |
import os | |
from time import sleep | |
WORKERS = 3 | |
_cnt = 0 | |
while _cnt < WORKERS: | |
_cnt += 1 | |
_pid = os.fork() | |
if _pid: | |
# master | |
print("pid {} forked".format(_pid)) | |
else: | |
sleep(3600) # awesome work here | |
print("all worker forked!") | |
sleep(3600) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment