如何解决如何在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 举报,一经查实,本站将立刻删除。