Dealing with thousands of threads termination

59 views
Skip to first unread message

Carlo Pires

unread,
Oct 20, 2012, 8:42:51 AM10/20/12
to gev...@googlegroups.com
Hi,

I have an application that spawns a very high number of threads. So, I was thinking that to keep a list to use gevent.joinall() to wait their termination would not be a good solution. So, I'd like to ask you for the best approaches to deal with such problem.

--
  Carlo Pires

Denis Bilenko

unread,
Oct 20, 2012, 8:53:13 AM10/20/12
to gev...@googlegroups.com
You can use gevent.wait() ( if you on trunk, in 1.0b4 it was called
gevent.run() )

It waits for everything without any overhead. You'd need to make sure
that you stop all servers though and any other things that do not
terminate naturally.

Carlo Pires

unread,
Oct 20, 2012, 10:56:20 AM10/20/12
to gev...@googlegroups.com

You can use gevent.wait() ( if you on trunk, in 1.0b4 it was called
gevent.run() )
 
That is exactly what I was looking for. Is there a way to iterate over
stalled threads if needed?

vitaly

unread,
Oct 22, 2012, 1:34:31 AM10/22/12
to gev...@googlegroups.com
> You can use gevent.wait()

gevent.joinall() takes a sequence of greenlets, while gevent.wait() takes a sequence of "objects" (???).  Are you suggesting calling gevent.wait() without any args or passing a sequence of greenlets via the "objects" arg?  Also, which types of objects are valid for passing inside the "objects" sequence in gevent.wait()?

Thank you,
Vitaly
Reply all
Reply to author
Forward
0 new messages