Is it necessary to use gevent api to implement "long running calls"

124 views
Skip to first unread message

Mengyu Zhang

unread,
May 15, 2014, 5:18:09 AM5/15/14
to zer...@googlegroups.com
In the PyCon lecture, I notice that zerorpc spawn a gevent thread for each request, to deal with the long-running call problem which would make the service run out of workers. 

My question is, Is it necessary to use gevent api to implement "long running calls", say 'gevent.sleep' or 'gevent.wait' ? If not, how the zerorpc make the context switch when a operation in user-implemented rpc blocks the current green thread? 

Mengyu Zhang

unread,
May 15, 2014, 5:32:43 AM5/15/14
to zer...@googlegroups.com
Okay, forget this. gevent will perform a switch when io is blocking. What a powerful lib ... 

The greenlets all run in the same OS thread and are scheduled cooperatively. This means that until a particular greenlet gives up control, (by calling a blocking function that will switch to theHub), other greenlets won’t get a chance to run. It is typically not an issue for an I/O bound app, but one should be aware of this when doing something CPU intensive, or when calling blocking I/O functions that bypass the libev event loop."  

在 2014年5月15日星期四UTC+8下午5时18分09秒,Mengyu Zhang写道:
Reply all
Reply to author
Forward
0 new messages