Skip to content

Commit c31ac7f

Browse files
author
Adrien Chauve
committed
Make worker maximum sleep time configurable
1 parent e6e13ee commit c31ac7f

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

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_sleep',
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ def work_loop(self):
408408
if len(jobs) < free_pool_slots:
409409
self.status = "wait"
410410
wait_count += 1
411-
gevent.sleep(min(1, 0.001 * wait_count))
411+
gevent.sleep(min(self.config["max_sleep"], 0.001 * wait_count))
412412

413413
except StopRequested:
414414
pass

0 commit comments

Comments
 (0)