A possible bug in python threading/time module?

Tim Peters tim.one at comcast.net
Fri Jul 4 15:38:01 EDT 2003


[Tim]
> Turns out that the Windows implementation of the Python C API function
> PyThread_start_new_thread() contained several "laziness" errors
>
> ...
>
> I'm testing putative fixes on a Win98 box and don't see any hangs any
> more. However, with more than about 3000 threads,
>
>     thread.error: can't start new thread
>
> gets raised because MS's _beginthread() fails (with errno == EAGAIN ==
> "there are too many threads").

FYI, these fixes have been checked in and will be part of 2.3 final (and
2.2.4, if that's ever released).

The maximum number of threads you can have alive simultaneously on 32-bit
Windows in an all-default Python build is actually about 2000.  This is
because each thread gets a megabyte of stack space by default, and 2048
threads would entirely exhaust the 31-bit user virtual address space just
for thread stacks.  If you want to know more about that, Google on

    CreateThread default stack size

The top hit is to the current relevant MSDN docs.






More information about the Python-list mailing list