Is there a way to know from which greenlet the current greenlet was spawned from in gevent?
- I realize that the greenlet which spawned the current greenlet might have terminated already, but in that case I would be ok with handling a None as an answer.
- I am aware of gevent.Greenlet.parent but this represents only the hub, not the direct greenlet from which the current greenlet was started from
- I would prefer a solution that does not involve monkey patching gevent.Greenlet
My use case is: I have a server which handles requests to execute python code (yes, yes, it is unsafe I know :-). Each request spawns a greenlet which handles the request, including redirecting any input, output or error to a channel private to the request. I want to be able to handle requests concurrently and the requests may spawn greenlets themselves.
You can find an example of what I am trying to do here