Skip to content

Flask with WSGI sync gives asyncio event loop errors. #244

Description

@CoultonF

If I use this in a WSGI flask application when you try to access a nested relationship pattern you get a threading error.

query {
  posts {
    id
    comments {
      text
      id
    }
  }
}
Stack trace:
There is no current event loop in thread 'Thread-8 (process_request_thread)'.
Traceback (most recent call last):
  File "/project/.venv/lib/python3.12/site-packages/strawberry/schema/schema.py", line 632, in execute_sync
    ensure_future(result).cancel()
    ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/tasks.py", line 693, in ensure_future
    loop = events.get_event_loop()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/events.py", line 702, in get_event_loop
    raise RuntimeError('There is no current event loop in thread %r.'
RuntimeError: There is no current event loop in thread 'Thread-8 (process_request_thread)'.

If I avoid using this package, and write out the fields and types it works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions