Skip to content

update flask sample #64

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

Open
wants to merge 1 commit into
base: v2_main
Choose a base branch
from
Open

Conversation

lloydzhou
Copy link

使用python内置的queue以及threading给出一个异步处理消息的示例,避免处理超时问题

  1. 创建一个线程,在worker中调用handler.do(request)处理业务逻辑
  2. flask的webhook接口接收事件后,调用parse_req()解析事件内容,并放入队列,立即返回,避免出现处理业务逻辑超时的问题。

@CLAassistant
Copy link

CLAassistant commented Mar 29, 2024

CLA assistant check
All committers have signed the CLA.

@lloydzhou
Copy link
Author

如果使用其他队列,例如rabbitmq之类的。

需要将parse_req()的内容做一下序列化(例如pickle.dumps)再放入队列。
处理的时候,再反序列化(对应的pickle.loads)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants