Error while killing gevent.greenlet

Skip to first unread message

Ayush Pratap Singh

May 30, 2023, 8:15:33 AMMay 30
to gevent: coroutine-based Python network library
My application uses gevent 22.10.2 tand greenlet 2.0.2

It is a TCP server which spawns 3 gevent.greenlets.
During disconnection flow when the code tries to kill the greenlets it throws an exception "Cannot convert greenlet.greenlet to gevent._gevent_c_greenlet_primitives.SwitchOutGreenletWithLoop" 

It occurs occassionally, say 1 out of 10 times.

This is how I'm creating and killing greenlets.

routine = gevent.spawn(Routine)

if routine:
    if not routine.dead:
        routine.kill() // exception thrown from here
    routine = None

These routines are also not blocked anywhere when kill is called.
Perhaps I'm doing something wrong? 
Reply all
Reply to author
0 new messages