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.
滿天的星座2017-07-05 10:36:24
Use gevent
, the coroutine solution,
pass the statement from gevent import monkey; monkey.patch_socket()
patch the IO
function, and you can set it to blocking
If you are using python3
, you can also use asyncio
, a coroutine solution that has been added to the standard library
Coroutines are syntactic sugar for asynchronous callbacks. Use synchronous writing to achieve asynchronous effects. You deserve it