Closed komuw closed 5 years ago
- when we execute the first task(or any other), we measure how long it took to execute
It appears that the method outlined above may not work
David Beazley, and Nathaniel J. Smith have weighed[1] in on the matter.
It appears that we could somehow do it, but it gets complicated[2] very fast.
ref:
Victor Stinner suggested[1];
It should be possible to write something on top of `ptrace` \
or something like that. \
Blocking I/O syscalls should be avoided from the thread running the event loop.
and also[2]
I implemented this simple debugging tool early in asyncio to detect blocking IO \
blocking the event loop. \
It uses a threshold of 100 ms by default, it is configurable
Fixed by:
Another option is to use python signal.alarm
https://github.com/ask/mode/blob/2ffae126df4893c3b2036cf6bb05d933362961c2/mode/debug.py
The code inside
async_run
; https://github.com/komuw/xyzabc/blob/ef3238de831e6b0c857328f8823b05295851bb17/xyzabc/task.py#L68should actually be async code with no blocking calls.
However, if a user were to write something like
The execution of
blocking_task
will also block execution ofnon_blocking_task
.This is because, python asyncio runs everything in one thread(in an event loop). It is thus important that users only put non-blocking code inside
async_run
methods. However, users may sometimes fail to do that. If they put blocking IO(or cpu), we should figure out how to;We have already institued measures to make sure that users do not change signature of
async_run
method to be non async; https://github.com/komuw/xyzabc/blob/e046a061b538586e5ddbd7aa2b47ed448f3f28c8/xyzabc/task.py#L233-L242We however need a way to check if code inside
async_run
is blocking and act.ref: