문제

I am still new to greenlets and gevent, but from what I understand, greenlets yield to other greenlets either on an explicit yield statement, or on a blocking I/O operation. But are writes to stdout using a print statement blocking? And what about using the logging module to write to stdout, stderr, or a file on a local disk, or NFS?

Can a call to a print statement or a logging method cause a greenlet switch?

도움이 되었습니까?

해결책

print statement is always blocking and will not switch to other greenlets. Avoid print instructions in any Gevent server code.

Newer Gevent versions have asynchronous file I/O gevent.os.tp_read that could be used with logging module to achieve non blocking operation. In this case log statements will cause Greenlet context switch.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top