Dataloader in multi-threaded environments
@Cito 已经在做这个了。
开始于 2019年12月10日。
评估
这个 Issue 还没有评估数据。
描述
Hi,
I've been thinking a bit about how we could implement the Dataloader pattern in v3 while still running in multi-threaded mode. Since v3 does not support Syrus's Promise library, we need to come up with a story for batching in async mode, as well as in multi-threaded environments. There are many libraries that do not support asyncio and there are many cases where it does not make sense to go fully async.
As far as I understand, the only way to batch resolver calls from a single frame of execution would be to use loop.call_soon. But since asyncio is not threadsafe, that means we would need to run a separate event loop in each worker thread. We would need to wrap the graphql call with something like this:
def run_batched_query(...):
loop = asyncio.new_event_loop()
execution_future = graphql(...)
loop.run_until_complete(result_future)
return execution_future.result()
Is that completely crazy? If yes, do you see a less hacky way? I'm not very familiar with asyncio so I would love to get feedback.
Cheers
- 主要语言
- Python
- 星标
- 531
- 派生
- 147
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
graphql-python/graphql-core 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 50/100
graphql-python/graphql-core#272 · 1 条评论 ·
-
难度 3/5 1-2 天 新手友好度 55/100
graphql-python/graphql-core#269 · 1 条评论 ·
-
难度 5/5 一周以上 新手友好度 35/100
graphql-python/graphql-core#267 · 1 条评论 ·
-
难度 3/5 1-2 天 新手友好度 45/100
graphql-python/graphql-core#257 ·
-
难度 5/5 一周以上 新手友好度 25/100
graphql-python/graphql-core#247 · 8 条评论 ·
查看 graphql-python/graphql-core 的全部 Issue
相似的 Issue
-
essnmx good first issue
难度 1/5 1 小时以内 新手友好度 95/100
-
难度 2/5 1-3 小时 新手友好度 65/100
syfoud/Simulated_Scepter#174 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
Giskard-AI/giskard-oss#2840 · 1 条评论 ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success 未关闭area: repo bug perceived difficulty: 2
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 2/5 1-3 小时 新手友好度 75/100
yeti-platform/yeti#1380 ·