Are min() and max() thread-safe?
Hendrik van Rooyen
hendrik at microcorp.co.za
Thu Sep 17 14:34:28 CEST 2009
On Thursday 17 September 2009 12:57:18 Carl Banks wrote:
> On Sep 17, 2:18 am, Hendrik van Rooyen <hend... at microcorp.co.za>
> When running min or max on a list of ints, there is probably no
> occasion for the function to release the GIL. If a thread doesn't
> release the GIL no other Python threads can run. This behavior may be
> rotten, but it's totally expected.
The lack of concurrency was not what I was complaining about, but the second
case that just quietly freaked out when I made the list of ints large.
I have subsequently seen that it is red herring in this context though, as it
is some memory problem - the crash comes during the list creation, and has
nothing to do with the min/max processing. One can demo it by simply trying
to create a big list at the interactive prompt, and after a while you get
the "Killed" message.
a = range(100000000) does it for me on my machine.
More information about the Python-list