Created
October 22, 2012 22:56
-
-
Save fmartingr/3935261 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def pid_exists(pid): | |
"""Check whether pid exists in the current process table.""" | |
if pid < 0: | |
return False | |
try: | |
os.kill(pid, 0) | |
except OSError, e: | |
return e.errno == errno.EPERM | |
else: | |
return True | |
def data_insert(db,collection,data): | |
#Hijo | |
process_c = os.fork() | |
if process_c == 0: | |
for a in range(1,10000): | |
db[collection].insert(data) | |
# os._exit(0) | |
#Padre | |
else: | |
while pid_exists(process_c): | |
print process_load() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment