Skip to content

Implement event loop blocking detection #7619

Description

@masenf

Summary

Detect event handlers that block the asyncio event loop (CPU-bound work or synchronous I/O inside an async handler, or a long-running sync handler executed inline) and report them clearly in dev mode, instead of letting the whole app turn sluggish with no indication of which handler is responsible.

Proposal

  • Wrap handler execution in the event processor with a blocking detector when running in dev mode. pyleak can detect a blocked loop around a code region; the alternative is a watchdog task that measures loop lag (scheduled wakeup vs actual wakeup) and attributes it to the handler running at that moment.
  • Report the handler's qualified name, how long the loop was blocked, and a hint: move the work to the thread pool executor (Explicit thread pool executor for sync event handlers #6225) or to a background event.
  • Off in prod by default, with a configurable threshold.

Related

Activity

  1. added
    roadmap
    on Oct 20, 2026
  2. added theissue type on Oct 20, 2026
  3. linear-code commented on Oct 20, 2026

    @linear-code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    roadmap

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions