Heroku上的gunicorn线程

Jon*_*han 4 multithreading heroku gunicorn

我正在尝试使用以下Procfile命令在Heroku上部署python Web应用程序:

web: gunicorn service:app --log-file=- --workers 1 --threads 4
Run Code Online (Sandbox Code Playgroud)

这会生成以下错误:

Traceback (most recent call last):
  File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 139, in load_class
    mod = import_module('.'.join(components))
  File "/app/.heroku/python/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/gthread.py", line 37, in <module>
    """)
RuntimeError:
    You need 'concurrent' installed to use this worker with this python version.
Run Code Online (Sandbox Code Playgroud)

由于我们不控制Heroku上的gunicorn安装,我该如何解决这个依赖问题呢?

奇怪的是,Heroku在他们的文档中没有提到gunicorn线程,只有工人.这有关系吗?

Meh*_*ghi 9

将这些行添加到您的requirements.txt:

futures==2.1.6
trollius==1.0.1
Run Code Online (Sandbox Code Playgroud)

将这些更改推送到您的heroku实例后,您将能够使用线程运行gunicorn.

concurrent是一个python 3.2包,并作为将来的包反向移植到python 2.7 .您应该至少使用python 3.2作为运行时,或者应该将反向移植的包添加到项目要求中.