Vendor DataLoader
from aiodataloader
and move get_event_loop()
out of __init__
function.
#1459
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
'sDataLoader
class into theutils/
moduleget_event_loop
out 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