Skip to content

Commit 96f586a

Browse files
committed
Merge pull request #67 from Serenytics/make-worker-maximum-sleep-time-configurable
Make worker maximum sleep time configurable
2 parents b7712f3 + 86a0a05 commit 96f586a

3 files changed

Lines changed: 11 additions & 6 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ nosetests.xml
3434
.project
3535
.pydevproject
3636

37+
.idea/
38+
3739
venv
3840
pypy
3941
.DS_Store

mrq/config.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,14 @@ def add_parser_args(parser, config_type):
296296
type=str,
297297
help='Overwrite the local IP, to be displayed in the dashboard.')
298298

299+
parser.add_argument(
300+
'--max_latency',
301+
default=1.,
302+
type=float,
303+
action='store',
304+
help='Max seconds while worker may sleep waiting for a new job. '
305+
'Can be < 1.')
306+
299307

300308
def get_config(
301309
sources=(

mrq/worker.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -377,11 +377,6 @@ def work_loop(self):
377377
self.status = "full"
378378
gevent.sleep(0.01)
379379

380-
quiet = not (wait_count % 20 == 0 or wait_count > 1000)
381-
382-
if not quiet:
383-
self.log.info('Fetching %s jobs from %s' % (free_pool_slots, self.queues))
384-
385380
jobs = []
386381

387382
for queue_name in self.queues:
@@ -410,7 +405,7 @@ def work_loop(self):
410405
if len(jobs) < free_pool_slots:
411406
self.status = "wait"
412407
wait_count += 1
413-
gevent.sleep(min(1, 0.001 * wait_count))
408+
gevent.sleep(min(self.config["max_latency"], 0.001 * wait_count))
414409

415410
except StopRequested:
416411
pass

0 commit comments

Comments
 (0)