我正在努力使Python标准队列在uWSGI master中工作。在
样本代码:
import queue, threading, time
from django.apps import AppConfig
my_queue = queue.Queue()
class MyApp(AppConfig):
def ready(self):
thread1 = threading.Thread(target=process_queue, args=())
thread1.daemon = True
thread1.start()
thread2 = threading.Thread(target=poll, args=())
thread2.daemon = True
thread2.start()
def poll():
while True:
time.sleep(1)
logging.info("Polling works every time")
def process_queue():
while True:
logging.info("I get here")
email = my_queue.get(block=True, timeout=None)
logging.info("I NEVER GET here. **I would like to get here**")
def put():
# I call this from the django views on requests
my_queue.put("1")
两个线程都启动。线程2按预期的定期打印。线程1永远等待队列,即使我从主线程添加到队列中(作为Django请求的一部分,在视图中)
我的uWSGI配置:
^{pr2}$请注意,如果我使用master = false
运行uWSGI,则一切都按预期工作
附加信息:
版本:
目前没有回答
相关问题 更多 >
编程相关推荐