如何在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()单独工作并等待队列为空?我需要确保没有覆盖文件,竞争条件或死锁。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)