Message162054
> conn = MySQLConn() > start_thread1(conn) > start_thread2(conn): > while True: > if os.fork() == 0: # child > raise Exception('doom') # triggers destructor There is no guarantee here that the lock will be held at the time of the fork. So even if we ensure that a lock acquired before the fork stayed lock, we won't necessarily get a deadlock. More importantly, you should never fork without ensuring that you exit with os._exit() or os.exec*(). So your example should be something like conn = MySQLConn() start_thread1(conn) start_thread2(conn): while True: if os.fork() == 0: # child try: raise Exception('doom') # does NOT trigger destructor except: sys.excepthook(*sys.exc_info()) os._exit(1) else: os._exit(0) With this hard exit the destructor never runs. | |
Date | User | Action | Args | 2012-06-01 06:58:59 | sbt | set | recipients: + sbt, gregory.p.smith, vinay.sajip, jcea, pitrou, vstinner, nirai, bobbyi, neologix, Giovanni.Bajo, sdaoden, avian, lesha | 2012-06-01 06:58:59 | sbt | set | messageid: <1338533939.6.0.779827783959.issue6721@psf.upfronthosting.co.za> | 2012-06-01 06:58:59 | sbt | link | issue6721 messages | 2012-06-01 06:58:58 | sbt | create | | |