code_junkie

Failed to get separate instances of a class under mod_python

Nov 11th, 2011
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. class Foo(object):
  2. pass
  3.  
  4. kidprocs = []
  5.  
  6. for kid in ('kid1', 'kid2'):
  7.  
  8. pid = os.fork()
  9. if pid:
  10. # parent
  11. kidprocs.append(pid)
  12. time.sleep(5)
  13. else:
  14. # child
  15.  
  16. fooobj = Foo()
  17. print "Starting %s in sub-process %s" % (kid, os.getpid())
  18. print "Kid fooobj: %s" % repr(fooobj)
  19. os._exit(0)
  20.  
  21. for kidproc in kidprocs:
  22. os.waitpid(kidproc, 0)
  23.  
  24. Starting kid1 in sub-process 20906
  25. foo obj: <__main__.Foo instance at 0xb7da5fec>
  26.  
  27. Starting kid2 in sub-process 20909
  28. foo obj: <__main__.Foo instance at 0xb7da5fec>
Add Comment
Please, Sign In to add comment