Heroku工作者超时3分钟

时间:2017-01-16 18:37:01

标签: python django heroku

我在Heroku上有一个Django应用程序,并且已经将一些报告处理代码移动到工作线程,因为它可能需要一些时间来生成。一切正常,除非报告生成时间超过三分钟。

每次我运行它,在3分钟标记 - 给予或花一秒钟 - 我在日志中看到“日志:无法从客户端接收数据:连接重置”,报告处理似乎停止

它不是死在同一个玩家身上,甚至不是同样的方法,但总是在同一时间。工人dynos有时间限制吗?在过去的几个小时里,我一直在学习文档而且找不到任何一个文档。

以下是日志的摘录:

Jan 16 10:14:06 myapp app/worker.1:  Generating all individual player reports 
Jan 16 10:14:06 myapp app/worker.1:  Beginning loop of players 
Jan 16 10:14:06 myapp app/worker.1:  Adding report data for player
Jan 16 10:14:06 myapp app/worker.1:  0 
Jan 16 10:14:06 myapp app/worker.1:  In get_player_report_data 
Jan 16 10:14:06 myapp app/worker.1:  In get player positions 
Jan 16 10:14:06 myapp app/worker.1:  In score_data_for_metric_category 
.....
Jan 16 10:17:01 myapp app/worker.1:  In get rank 
Jan 16 10:17:02 myapp app/worker.1:  Finished get rank 
Jan 16 10:17:02 myapp app/worker.1:  In score_data_for_metric_category 
Jan 16 10:17:02 myapp app/worker.1:  In get rank 
Jan 16 10:17:05 myapp app/postgres.27698:  [PINK] [7-1] LOG:  could not receive data from client: Connection reset by peer 

我的proc文件中的工作人员声明行只是:

worker: python worker.py

worker.py文件基本上取自Heroku文档:

import os

import redis
from rq import Worker, Queue, Connection

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myapp.settings")

from django.core.wsgi import get_wsgi_application
from dj_static import Cling

application = Cling(get_wsgi_application())

listen = ['high', 'default', 'low']

redis_url = os.getenv('REDISTOGO_URL', 'redis://localhost:6379')

conn = redis.from_url(redis_url)

if __name__ == '__main__':
    with Connection(conn):
        worker = Worker(map(Queue, listen))
        worker.work()

我用以下方式启动报告生成:

from rq import Queue
from worker import conn

q = Queue(connection=conn)
q.enqueue(generate_all_individual_player_reports, group_id, notes, request.user.email)

0 个答案:

没有答案