-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
validate that code inside Task.async_run
is not blocking
#4
Comments
Task. async_run
is not blockingTask.async_run
is not blocking
It appears that the method outlined above may not work |
David Beazley, and Nathaniel J. Smith have weighed[1] in on the matter. ref: |
PR: to add task blocked watchdog to trio ref: |
Victor Stinner suggested[1];
and also[2]
|
Fixed by:
|
Another option is to use python 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.-if that attribute is True, we start a thread and all other task executions of that task will be done on the thread.
ref:
The text was updated successfully, but these errors were encountered: