greenlets are lightweight, but if there are enough of them running that a second list of references to them is a problem...well, I'd think you'd probably hit other limitations long before that happens.
> Can anybody suggest some cleaner ways of doing this?
The requirements for the argument to joinall are that it be iterable and support __len__. So in this case that's easily accomplished with a little helper class:
class ToJoin:
def __len__(self):
return len(list_of_greenlets) + 1
def __iter__(self):
for g in list_of_greenlet:
yield g
yield another_greenlet
gevent.joinall(ToJoin())
Basically itertools.chain() plus __len__.
Also, know that gevent.joinall() collects and returns the greenlets that finish so their results can be inspected. So you'll wind up with that extra list of greenlets no matter what you do :)
Why does it do that? Because code like this is pretty common:
results = gevent.joinall([gevent.spawn(func, x) for x in data])
(You can use iwait() to avoid the list, but you have to be more careful with it.)
Jason