Are gevent.spawn_link_exception and friends gone in gevent v1.0 permanently?

348 views
Skip to first unread message

vitaly

unread,
May 15, 2012, 8:26:37 PM5/15/12
to gevent: coroutine-based Python network library
I tried to switch my app from gevent 0.13.x to v1.0b2 and found a few
things to be missing:

gevent.spawn_link_exception
gevent.greenlet.LinkedFailed and friends


Also, Greenlet.link_exception(self, receiver=None,
SpawnedLink=FailureSpawnedLink) provides a default value for receiver,
but raises an exception if called without a receiver:

>>
/Users/vkruglikov/Packages/gevent-1.0b2/gevent-1.0b2/build/
lib.macosx-10.7-intel-2.6/gevent/greenlet.pyc in __init__(self,
callback)
20 def __init__(self, callback):
21 if not callable(callback):
---> 22 raise TypeError("Expected callable: %r" %
(callback, ))
23 self.callback = callback
24
<<

Thank you,
Vitaly

Denis Bilenko

unread,
May 16, 2012, 5:19:12 AM5/16/12
to gev...@googlegroups.com
On Wed, May 16, 2012 at 4:26 AM, vitaly <vitaly.kru...@gmail.com> wrote:
> I tried to switch my app from gevent 0.13.x to v1.0b2 and found a few
> things to be missing:
>
> gevent.spawn_link_exception
> gevent.greenlet.LinkedFailed and friends

Yes, "linking to greenlet" feature was removed in 1.0.

Johan Rydberg

unread,
May 16, 2012, 12:47:21 PM5/16/12
to gev...@googlegroups.com
Is there a way to accomplish the same functionality, without
subclassing Greenlet?

Denis Bilenko

unread,
May 16, 2012, 1:09:34 PM5/16/12
to gev...@googlegroups.com
On Wed, May 16, 2012 at 8:47 PM, Johan Rydberg <johan....@gmail.com> wrote:
> Is there a way to accomplish the same functionality, without
> subclassing Greenlet?

Sure, just pass a callable to link() that will kill() your greenlet.

one_greenlet.link(lambda *args:
another_greenlet.kill(Exception('one_greenlet is dead'))

However, using kill() and asynchronous exceptions in general is not
recommended. Best to structure your program differently so you don't
need it.
Reply all
Reply to author
Forward
0 new messages