I have always had some questions. Are some functions and common libraries of python blocking? For example, print, socket connection, etc. Are there any simple solutions for blocking, non-blocking, asynchronous, etc.?
Is there any clear language support for asynchronous parallelism? I have used nodejs callbacks and can't stand it. The latest ES seems to have improved.
Use
gevent
, the coroutine solution,pass the statement
from gevent import monkey; monkey.patch_socket()
patch theIO
function, and you can set it to blockingIf you are using
python3
, you can also useasyncio
, a coroutine solution that has been added to the standard libraryCoroutines are syntactic sugar for asynchronous callbacks. Use synchronous writing to achieve asynchronous effects. You deserve it