[Python-ideas] Flagging blocking functions not to be used with asyncio

Nathaniel Smith njs at pobox.com
Mon Oct 10 11:32:19 EDT 2016


On Mon, Oct 10, 2016 at 2:59 AM, Martin Teichmann
<lkb.teichmann at gmail.com> wrote:
> This is why I got my idea to flag such calls. Unfortunately, I
> realized that it is nearly impossible to tell whether a read call is
> blocking or not. We would need to know whether the file descriptor we
> read from was created as non-blocking, or whether it was an actual
> file, and how fast the file storage is for this file (SSD: maybe fine,
> Network: to slow, magnetic disk: dunno). All of this is unfortunately
> not a Python issue, but an issue for the underlying operating system.

Yeah, it really doesn't help that a synchronous network query to a
remote SSD-backed database can easily be lower latency than a
synchronous local disk read to spinning media, yet the fact that we
have async network APIs but no standard async disk APIs means that we
would inevitably find ourselves warning about the former case while
letting the latter one pass silently...

-n

-- 
Nathaniel J. Smith -- https://vorpus.org


More information about the Python-ideas mailing list