jaberg/hyperopt — pull request #138 by twiecki (2013-07-03 20:08:50+00:00)
Title: Update timer if no jobs found by mongo worker.

I noticed that keeping a mongo-worker running without submitting a job for a long time causes timeouts in `run_one()`. I think the cause is this logic:

```python
start_time = time.time()
mj = self.mj
while job is None:
if (reserve_timeout
and (time.time() - start_time) > reserve_timeout):
raise ReserveTimeout()
job = mj.reserve(host_id, exp_key=self.exp_key)
if not job:
interval = (1 +
numpy.random.rand()
* (float(self.poll_interval) - 1.0))
logger.info('no job found, sleeping for %.1fs' % interval)
time.sleep(interval)
```

Essentially if there are no jobs submitted the timer just keeps on running until it time-outs. Resetting the timer changes this behavior.