Skip to content

Instantly share code, notes, and snippets.

@fmartingr
Created October 22, 2012 22:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fmartingr/3935261 to your computer and use it in GitHub Desktop.
Save fmartingr/3935261 to your computer and use it in GitHub Desktop.
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