I was just planning to rewrite some python code in which I was polling a file for changes. I wanted to rewrite it as an exercise for asyncio
and the conceptual idea was to do a nonblocking file read that would yield. Once the data is available the event loop would continue the coroutine execution.
Then I discovered that async file operations isn't something one does. ref.
But I couldn't understand what is the motivation for this behavior and how why would it be any different than for sockets.
Socket example:
Reading a socket yields from a coroutine until the data is ready. Ready meaning it actually arrived in an nondeterministic time from somewhere on the Internet.
Why not also for reading a file:
Reading a file yields from a coroutine until the data is ready. Ready meaning it actually arrived in an nondeterministic time from somewhere from the hard disk of the computer
Is this an inherited behavior from legacy code that works well enough with blocking calls?
Does it something to do with Character vs Block files?
What about character device files, say a file representing a UART connection? Would the no file IO also be applied here?