At PyTennessee 2018 I gave a talk about writing Python object destructors called What To Expect When You’re Expiring: Rules for __del__. The rules for a destructor method are:

  1. Don’t access modules or globals.
  2. Don’t access threadlocals.
  3. Don’t take any locks.

Links to further reading about the subject:

The images I used in my slides are from: