Uwsgi+Flask+pylibmc:定义线程减少

2024-05-13 07:43:55 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个Flask应用程序,它在uwsgi后面运行,在app.ini文件中有这些设置:

...
processes=1
threads=2
...

应用程序在一个具有通用烧瓶结构的文件中定义:

^{pr2}$

我也使用pylibmc来访问ElastiCache,但是考虑到uwsgi生成线程和进程,并且pylibmc.客户是非常非线程安全的,因此我得到了很多错误。在

Of course this requires that you let the pool know when a thread is done with its reserved instance, so therefore relinquish must be called before thread exit.

但是我不手工生成线程,所以我不知道在哪里定义析构函数来调用池上的relinquish以避免死连接。在

问题是:在uwsgi隐式创建线程的情况下,如何定义线程析构函数?


Tags: 文件函数app应用程序flask定义烧瓶线程