Further Reading About What To Expect When You're Expiring
source link: https://emptysqua.re/blog/further-reading-what-to-expect-when-youre-expiring/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Further Reading About What To Expect When You're Expiring
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:
- Don’t access modules or globals.
- Don’t access threadlocals.
- Don’t take any locks.
Links to further reading about the subject:
- PEP 442 makes Rule 1 less necessary. For an entertaining story about this rule, read A Normal Accident In Python and mod_wsgi.
- Python’s Thread Locals Are Weird. The horror story behind Rule 2: “Don’t touch threadlocals”.
- PyPy, Garbage Collection, And A Deadlock: More details about Rule 3.
- All the code examples used in my talk.
The images I used in my slides are from:
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK