fork download
  1. import weakref
  2. import threading
  3.  
  4.  
  5. def do(l):
  6. l.acquire()
  7.  
  8.  
  9. class A:
  10. def __init__(self):
  11. l = threading.Lock()
  12. l.acquire()
  13. t = threading.Thread(target=do, args=[l])
  14. t.start()
  15.  
  16. weakref.finalize(self, A._finalize, t, l)
  17.  
  18. @staticmethod
  19. def _finalize(t, l):
  20. print("finalizing")
  21. l.release()
  22. t.join()
  23.  
  24.  
  25. a = A()
  26. # del a does trigger _finalize though
Time limit exceeded #stdin #stdout 5s 9900KB
stdin
Standard input is empty
stdout
Standard output is empty