Vendor DataLoader from aiodataloader and move get_event_loop() out of __init__ function.#1459
Merged
erikwrede merged 5 commits intoSep 7, 2022
Merged
Vendor DataLoader from aiodataloader and move get_event_loop() out of __init__ function.#1459erikwrede merged 5 commits into
DataLoader from aiodataloader and move get_event_loop() out of __init__ function.#1459erikwrede merged 5 commits into
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1459 +/- ##
==========================================
+ Coverage 95.44% 95.72% +0.27%
==========================================
Files 49 50 +1
Lines 1582 1683 +101
==========================================
+ Hits 1510 1611 +101
Misses 72 72
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
DataLoader from aiodataloader and move get_event_loop() out of __init__ function.DataLoader from aiodataloader and move get_event_loop() out of __init__ function.
flipbit03
commented
Sep 5, 2022
|
|
||
| # This is a specific ignore for Black+Flake8 | ||
| # source: https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#id1 | ||
| extend-ignore = E203 |
Contributor
Author
There was a problem hiding this comment.
without this line, flake8 was constantly clashing with black over array slice notation whitespacing rules.
Member
|
Seems like |
…avior from `__init__` to a property which only gets resolved when actually needed (this will solve PyTest-related early get_event_loop() issues)
…executed by pytest.
…ility to pass in a custom event loop, if needed.
erikwrede
approved these changes
Sep 6, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DataLoaders are trying to get the asyncio's event loop too early (on
__init__) and this is generating problems like making pytest + async unusable. Since there is no event loop at that moment, the first DataLoader instantiated is actually creating a new event loop. This generates the infamous "Future tied to a different loop" problem many people are facing.In this PR, we are:
aiodataloader'sDataLoaderclass into theutils/moduleget_event_loopout of the class' initializer and into a property which only gets called when actually needed, offsetting the chicken-and-egg problem we are dealing with.The base for this work is dataloader.py, which is MIT Licensed code from Syrus Akbary