destructor_test.py 671 B

12345678910111213141516171819202122232425262728293031323334
  1. from time import sleep
  2. from PyQt4 import QtCore
  3. from FlatCAMWorker import Worker
  4. class MyObj():
  5. def __init__(self):
  6. pass
  7. def __del__(self):
  8. print "##### Distroyed ######"
  9. def parse():
  10. o = MyObj()
  11. raise Exception("Intentional Exception")
  12. if __name__ == "__main__":
  13. qo = QtCore.QObject
  14. worker = Worker(qo)
  15. thr1 = QtCore.QThread()
  16. worker.moveToThread(thr1)
  17. qo.connect(thr1, QtCore.SIGNAL("started()"), worker.run)
  18. thr1.start()
  19. while True:
  20. try:
  21. parse()
  22. print "Parse returned."
  23. except Exception:
  24. pass
  25. sleep(5)
  26. print "Competed successfully."