Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • 1
    But aren't the typical API calls always blocking. For e.g. requests module in python, you make the API call, and wait for the response. Commented Aug 1, 2024 at 13:51
  • @Eric no, typical systems have non-blocking APIs. There may be blocking wrappers around those, but non-blocking is the norm. Commented Aug 1, 2024 at 13:52
  • Blocking APIs in a thread block that thread, but other threads can keep running. If you have four cores and 20 threads, 16 threads can be blocked and the other four still run at full speed. Commented Aug 1, 2024 at 14:20
  • @Eric I've just looked at the timeline, and the requests module comes from a point in Python's history where a blocking api was much simpler to use than a non-blocking api, it predates async / await. A number of libraries came later, and were able to chose to be non-blocking whilst still being simple to use. The underlying system calls these libraries use to do networking are all non-blocking. Commented Aug 1, 2024 at 14:39