Skip to content

Commit

Permalink
Merge pull request #212 from yannpom/master
Browse files Browse the repository at this point in the history
Option to undaemonize workers and allows them to spawn child processes
  • Loading branch information
Koed00 authored Dec 5, 2016
2 parents ab87b9b + 78b997e commit 82c48cd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions django_q/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ def spawn_process(self, target, *args):
p = Process(target=target, args=args)
p.daemon = True
if target == worker:
p.daemon = Conf.DAEMONIZE_WORKERS
p.timer = args[2]
self.pool.append(p)
p.start()
Expand Down
3 changes: 3 additions & 0 deletions django_q/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ class Conf(object):
# sensible default
WORKERS = 4

# Option to undaemonize the workers and allow them to spawn child processes
DAEMONIZE_WORKERS = conf.get('daemonize_workers', True)

# Maximum number of tasks that each cluster can work on
QUEUE_LIMIT = conf.get('queue_limit', int(WORKERS) ** 2)

Expand Down
6 changes: 6 additions & 0 deletions docs/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ workers

The number of workers to use in the cluster. Defaults to CPU count of the current host, but can be set to a custom number. [#f1]_

daemonize_workers
~~~~~~~~~~~~~~~~~

Set the daemon flag when spawning workers. You may need to disable this flag if your worker needs to spawn child process but be carefull with orphaned child processes in case of sudden termination of the main process.
Defaults to ``True``.

recycle
~~~~~~~

Expand Down

0 comments on commit 82c48cd

Please sign in to comment.