-
-
Notifications
You must be signed in to change notification settings - Fork 541
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
Prevent the debug server from setting up its own event loop #945
Prevent the debug server from setting up its own event loop #945
Conversation
338005b
to
0247153
Compare
Codecov Report
@@ Coverage Diff @@
## main #945 +/- ##
==========================================
+ Coverage 97.41% 97.52% +0.10%
==========================================
Files 76 76
Lines 2592 2705 +113
Branches 362 378 +16
==========================================
+ Hits 2525 2638 +113
Misses 41 41
Partials 26 26 |
@@ -57,4 +57,4 @@ def server(schema, host, port, app_dir): | |||
app.add_websocket_route(path, graphql_app) | |||
|
|||
print(f"Running strawberry on http://{host}:{port}/ 🍓") | |||
uvicorn.run(app, host=host, port=port, log_level="error") | |||
uvicorn.run(app, loop="none", host=host, port=port, log_level="error") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this documented in the uvicorn docs? I was only able to find it here: https://github.com/encode/uvicorn/blob/bf1c64e2c141971c546671c7dc91b8ccf0afeb7d/uvicorn/config.py#L55-L60
I'll test this with the dataloader example and see if it works :)
Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears to be undocumented on their website which matches the uvicorn cli help command. Maybe it was intended for programmatically usage only. However, according to this PR they added it specifically to allow the setup of custom event loops.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tested and it seems to work! Good spot!
Thanks for adding the Here's a preview of the changelog: This releases fixes an issue with the debug server that prevented the |
Description
This PR is a possible fix for #940. It configures
uvicorn
to not create its own event loop. This way thestrawberry.dataloader.DataLoader.loop
would be the same as the loop used byuvicorn
.While I would probably not configure
uvicorn
the same way in production code, I think it's the simplest (maybe the only) way to make dataloaders work with the debug server command.Types of Changes
Issues Fixed or Closed by This PR
Checklist