Skip to content

Commit

Permalink
fix: exclude non-tasks app configs outside loop
Browse files Browse the repository at this point in the history
This should reduce Cognitive Complexity
  • Loading branch information
denizdogan committed Mar 27, 2019
1 parent 0d29118 commit a636830
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions django_dramatiq/management/commands/rundramatiq.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,20 @@ def handle(self, use_watcher, use_polling_watcher, use_gevent, path, processes,
os.execvp(executable_path, process_args)

def discover_tasks_modules(self):
app_configs = apps.get_app_configs()
# Get configs of apps where there is a tasks module
app_configs = (
conf for conf in apps.get_app_configs()
if module_has_submodule(conf.module, "tasks")
)
tasks_modules = ["django_dramatiq.setup"]
ignored = getattr(settings, 'DRAMATIQ_IGNORED_MODULES', [])
for conf in app_configs:
if module_has_submodule(conf.module, "tasks"):
module = conf.name + ".tasks"
if module in ignored:
self.stdout.write(" * Ignored tasks module: %r" % module)
continue
tasks_modules.append(module)
self.stdout.write(" * Discovered tasks module: %r" % module)
module = conf.name + ".tasks"
if module in ignored:
self.stdout.write(" * Ignored tasks module: %r" % module)
continue
tasks_modules.append(module)
self.stdout.write(" * Discovered tasks module: %r" % module)
return tasks_modules

def _resolve_executable(self, exec_name):
Expand Down

0 comments on commit a636830

Please sign in to comment.