[Chore/Refactor] adapt async / await #16004

Open
opened 2026-02-21 19:24:18 -05:00 by yindo · 6 comments
Owner

Originally created by @asukaminato0721 on GitHub (Aug 8, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for refactoring, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Description

Now this project uses gevent, but mainstream uses async / await.

it requires several steps, so this will involve several pr.

Motivation

better maintainness.

and better third lib.

Additional Context

No response

Originally created by @asukaminato0721 on GitHub (Aug 8, 2025). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for refactoring, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Description Now this project uses gevent, but mainstream uses async / await. it requires several steps, so this will involve several pr. - [x] #24006 - [ ] flask -> fastapi or https://github.com/pallets/quart ? which seems maybe easier? - [ ] ~~sqlachemy -> it's async engine~~ ... ### Motivation better maintainness. and better third lib. ### Additional Context _No response_
Author
Owner

@EchterTimo commented on GitHub (Aug 13, 2025):

+1

@EchterTimo commented on GitHub (Aug 13, 2025): +1
Author
Owner

@asukaminato0721 commented on GitHub (Aug 22, 2025):

https://palletsprojects.com/ oh, quart is kind of official flask async version, but first use flask async version...

@asukaminato0721 commented on GitHub (Aug 22, 2025): https://palletsprojects.com/ oh, quart is kind of official flask async version, but first use flask async version...
Author
Owner

@yihong0618 commented on GitHub (Aug 22, 2025):

flask -> fastapi or https://github.com/pallets/quart ? which seems maybe easier?

its hard all use flask include the database mirgrate

just using flask async is better

@yihong0618 commented on GitHub (Aug 22, 2025): flask -> fastapi or https://github.com/pallets/quart ? which seems maybe easier? its hard all use flask include the database mirgrate just using flask async is better
Author
Owner

@dosubot[bot] commented on GitHub (Sep 22, 2025):

Hi, @asukaminato0721. I'm Dosu, and I'm helping the Dify team manage their backlog and am marking this issue as stale.

Issue Summary

  • You proposed refactoring the project to replace gevent with async/await for better maintainability and third-party library support.
  • The plan involves a multi-step migration: moving from Flask to FastAPI or Quart and updating SQLAlchemy to async.
  • Discussion includes whether to switch to FastAPI or Quart, with suggestions that using Flask's async support might be simpler.
  • Comments highlight the complexity of migrating both the database and framework simultaneously.
  • The proposal has received some positive feedback, including a +1 from EchterTimo.

Next Steps

  • Please let me know if this issue is still relevant to the latest version of Dify by commenting here to keep the discussion open.
  • Otherwise, I will automatically close this issue in 15 days.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Sep 22, 2025): Hi, @asukaminato0721. I'm [Dosu](https://dosu.dev), and I'm helping the Dify team manage their backlog and am marking this issue as stale. **Issue Summary** - You proposed refactoring the project to replace gevent with async/await for better maintainability and third-party library support. - The plan involves a multi-step migration: moving from Flask to FastAPI or Quart and updating SQLAlchemy to async. - Discussion includes whether to switch to FastAPI or Quart, with suggestions that using Flask's async support might be simpler. - Comments highlight the complexity of migrating both the database and framework simultaneously. - The proposal has received some positive feedback, including a +1 from EchterTimo. **Next Steps** - Please let me know if this issue is still relevant to the latest version of Dify by commenting here to keep the discussion open. - Otherwise, I will automatically close this issue in 15 days. Thank you for your understanding and contribution!
Author
Owner

@EchterTimo commented on GitHub (Jan 31, 2026):

So how are we going to continue with this issue?

@EchterTimo commented on GitHub (Jan 31, 2026): So how are we going to continue with this issue?
Author
Owner

@asukaminato0721 commented on GitHub (Jan 31, 2026):

So how are we going to continue with this issue?

https://github.com/langgenius/dify/issues/30269

@asukaminato0721 commented on GitHub (Jan 31, 2026): > So how are we going to continue with this issue? https://github.com/langgenius/dify/issues/30269
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#16004