1
我想通過cron作業來請求多線程中的API。我期待停止或放鬆請求的線程。 這是pserve
沒有問題。我想使用uWSGI
但我有一些問題。多線程requests.post使用uWSGI,金字塔
的Python 3.5.2
我的代碼是這樣的:
import threading
import requests
def worker(settings):
lookup_url = settings['lookup_url']
api_sid = settings['api_sid']
auth_token = settings['auth_token']
args = settings['args']
resp = requests.post(lookup_url,
auth=(api_sid, auth_token),
data={'data': args},
timeout=5.0,
)
def main(request):
registry = request.registry
settings = registry.settings
for _ in range(3):
threading.Thread(target=worker, args=(settings,)).start()
請讓我知道任何解決方案。
太謝謝你了。 我試過了,看起來不錯。 >>> [uwsgi] enable-threads = true – terapyon