I'm assuming that the definition of asynchronous is as follows.
- Let's start with a relationship between two 'things': X and Y.
- They can be anything, e.g. X can be you and Y can be your washing machine.
- Let's say X requests something of Y.
- This can also be anything: a question, a task.
- Let's say we live in a world where Y cannot immediately respond with the answer / completion status.
- What happens?
- In a Synchronous relationship, you 'wait around' in some way.
- This could involve just sitting there or asking repeatedly.
- In an Asynchronous relationship, you go on with your life.
- Y will ping you when it's done.
- In a Synchronous relationship, you 'wait around' in some way.
- What happens?
From the perspective of a user's API, node.js and asyncio seem asynchronous. For example, in node.js you can register callbacks upon completion of certain events. And in asyncio, the callback logic goes right after some await my_io()
.
But here's my question - are node.js and asyncio actually truly asynchronous? Implementation-wise, do they just engage in a bunch of frantic non-blocking "hey, is this file descriptor free yet?" calls or is it actually interrupt-driven?