Skip to content

sync_to_async detects deadlock in case of issue in loop.run_in_executor #495

Open
@namezys

Description

@namezys

Long story:

  • We randomly get a run time error: "Single thread executor already being used, would deadlock"`.
  • However, there was another error: RuntimeError: cannot schedule new futures after shutdown.
    I started to investigate, but it was unclear what error caused this issue.

Even if it does not solve my bugs, I found that exception from loop.run_in_executor in "SyncToAsync.call" results in marking deadlock_context of SyncToAsync set true forever. Of course, this code can not work anymore, but this error is hiding real issues.

Looks like this bug can not affect the correct execution, but I spent too much time to realise that there is no problem related to deadlocks in sync_to_async.

Probably, I will be able to submit fix of it. It's pretty easy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions