Home  >  Q&A  >  body text

Asynchronous - Are some of Python's built-in functions blocking or non-blocking?

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.

黄舟黄舟2633 days ago890

reply all(1)I'll reply

  • 滿天的星座

    滿天的星座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

    reply
    0
  • Cancelreply