[Tutor] Fwd: question about number of threads

shawn bright nephish at gmail.com
Thu Oct 12 16:16:10 CEST 2006


---------- Forwarded message ----------
From: shawn bright <nephish at gmail.com>
Date: Oct 12, 2006 9:15 AM
Subject: Re: [Tutor] question about number of threads
To: Kent Johnson <kent37 at tds.net>

oh, well then i do not have anything to worry about. I was  talking about a
move from 6 threads to 10. he he. Thanks for the advice !

shawn

On 10/12/06, Kent Johnson <kent37 at tds.net> wrote:
>
> shawn bright wrote:
> > Hey there,
> > i have an app that runs several processes as threads.
> > using the threading.Thread()
> >
> > now, i have another app that does the same thing. Now, pretty soon, we
> > will be combining all the features of the two packages together into one
> > app.
> >
> > My question is, is there a limit on how many threads one GUI application
> > can have running in the background ?
> > Most of them are sleeping most of the time. They wake up and do
> > something every 10 seconds, 20 minutes, etc...
>
> IIRC the number of threads is limited by memory - each thread requires
> some heap space for its stack, etc. I don't think you will have trouble
> until you have hundreds or thousands of threads.
>
> For example on my computer this program prints 1031 before it exits with
> thread.error: can't start new thread:
>
> import time
> from threading import Thread, activeCount
>
> def run():
>      while 1:
>          time.sleep(1)
>
> while 1:
>      print activeCount()
>      t=Thread(target=run)
>      t.setDaemon(1)
>      t.start()
>
> (The setDaemon() call lets the application exit normally when it gets an
> exception; otherwise it hangs with all the threads running.)
>
> Kent
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20061012/db3d07cb/attachment.html 


More information about the Tutor mailing list