Thread limits?
Tim Peters
tim_one at email.msn.com
Sat Aug 19 22:13:32 EDT 2000
[Quasimodo]
> Pretty new to Python, and was messing about with multi-threading
> (also new).
>
> Is there a theoretical limit to the maximum number of threads that can be
> spawned?
No, but any particular platform will have a rather small *practical* limit!
> My machine (450MHz PIII, 320Mb RAM, Win98SE) tends to do it's dead-ant
> impersonation at around 1,000 threads created. Each thread at the mo just
> sleeps for 60 seconds, but eventually each will be updating a
> database every minute and running continuously, leading me to think I'll
> be lucky running 100-200 on this machine.
If you think you need 1,000 threads, you're solving the wrong problem or
solving the right one in a doomed way <wink>. Use the Queue (std library)
module to enter requests for work. Spin off a small number of threads, each
structured like so:
while 1:
request = your_queue_object.get() # sleeps until queue is non-empty
request.deal_with_it() # do whatever work it asks for
> Just wondering if anyone's got some input on any limits.
Ain't limits you're after, it's a sensible approach <wink>.
if-you-had-a-thousand-things-to-do-at-once-you'd-start-thrashing-too-ly
y'rs - tim
More information about the Python-list
mailing list