gpt4 book ai didi

python - Beanstalkc 超时问题

转载 作者:行者123 更新时间:2023-11-30 23:51:58 25 4
gpt4 key购买 nike

我在 Python 中使用 beanstalkc 来为必须解析 URL 列表的程序进行排队过程。因此,我在 beanstalk 中使用超时来避免任何 URL 消耗大量时间。但即使在使用它之后,我的进程也不会在限制内超时,并且需要花费大量时间来解析少数 URL。我正在使用以下代码:

for seed in seedlist:
print 'Put data: %s' % seed
bean.put(seed,ttr =5)
while True:
job = bean.reserve()
spider.spider(job.body)
print 'Got data: %s' % job.body

最佳答案

我认为您误解了 beanstalkd 的 TTR 超时的目的。引用 beanstalkd FAQ :

How does TTR work

TTR only applies to a job at the moment it becomes reserved. At that event, a timer (called “time-left” in the job stats) starts counting down from the job’s TTR.

  • If the timer reaches zero, the job gets put back in the ready queue.
  • If the job is buried, deleted, or released before the timer runs out, the timer ceases to exist.
  • If the job is "touch"ed before the timer reaches zero, the timer starts over counting down from TTR.

(The job stats of a job that isn’t reserved still contain a “time-left” entry, but its value is meaningless.)

因此,TTR 不能帮助您“避免任何 URL 消耗大量时间”。它不会神奇地杀死你的工作进程。它所做的只是,如果工作人员在给定时间跨度(TTR)后未将作业标记为已完成,beanstalkd 会将作业放回到队列中。

关于python - Beanstalkc 超时问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6504114/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com