python - 如何在python中创建一个单独的处理队列?
问题描述
我开发了一个使用 python 下载歌曲的电报机器人。我的程序将输入作为来自用户的链接并存储在队列中。如果队列中有项目,我有一个处理队列的函数,否则等待队列被填充。我的功能是
global my_queue
my_queue =[]
def process_queue():
if my_queue !=None:
#download the songs from the queue and send it to the user
else:
#wait for the queue to be filled
@run_async
def get_input():
#get input from the user and append the queue list with the item
如何使我的函数 process_queue() 单独工作并等待队列为空?我需要确保没有覆盖文件或竞争条件或死锁。
解决方案
推荐阅读
- go - 如何避免 golang 函数在调用嵌入类型和嵌入类型之间具有不同的行为?
- azure - 从 Azure Kubernetes 服务使用 Azure 容器注册表进行身份验证时的问题
- html - html - 图像和 svg 元素
- jquery - 依赖下拉列表 - Jquery - Ajax
- asp.net-web-api - 部署机器上的 Asp.Net Core 2.1 Angular 模板将环境检测为“开发”
- docker - 如何在 Docker for Windows 中设置共享驱动器?
- java - 我想使用 java 在 mongo db 的集合中更新具有多个查询的文档
- javascript - 未捕获的类型错误:无法读取 materialize.js 中未定义的属性“顶部”
- c# - 基于条件 jquery 选中未选中的 JsTree Checkbox
- hyperledger-fabric - 如何将超级账本作曲家模型文件中的主键组合为标识符?