Multiprocessing / threading confusion

Chris Angelico rosuav at gmail.com
Thu Sep 5 23:00:49 EDT 2013


On Fri, Sep 6, 2013 at 9:34 AM, Paul Pittlerson <menkomigen6 at gmail.com> wrote:
> On Friday, September 6, 2013 1:28:39 AM UTC+3, mar... at python.net wrote:
>
>> Also you can't (and shouldn't) depend on the time that __del__ gets
>> called.  It can get called at any time, in any order and sometimes not
>> at all.*
>
> Wow I did not know that! I was counting on that it reliably gets called when the object is destroyed.

Even that isn't technically reliable, though in CPython, objects will
usually be __del__'d promptly as long as they're not in reference
cycles.  But the main problem here is that the destruction of the
object has nothing to do with the ending of the thread or process; the
object will hang around for as long as the caller might want it.
You'll want to put your "end of process" code at the bottom of run(),
I think, unless there's some other place for it.

ChrisA



More information about the Python-list mailing list