Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: '_NamespacePath' object does not support indexing #98

Closed
thebjorn opened this issue May 4, 2021 · 1 comment
Closed

TypeError: '_NamespacePath' object does not support indexing #98

thebjorn opened this issue May 4, 2021 · 1 comment

Comments

@thebjorn
Copy link

thebjorn commented May 4, 2021

I've modified the code to print out the module path that fails:

go|c:\srv\www\nhosh> python manage.py rundramatiq
MODULE:PATH: None
 * Discovered tasks module: 'django_dramatiq.tasks'
MODULE:PATH: ['c:\\srv\\lib\\norsk\\norsk\\tasks']
 * Discovered tasks module: 'norsk.tasks.update_words'
MODULE:PATH: _NamespacePath(['c:\\srv\\lib\\qm\\qm\\tasks'])
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "c:\srv\venv\dev35\lib\site-packages\django\core\management\__init__.py", line 354, in execute_from_command_line
    utility.execute()
  File "c:\srv\venv\dev35\lib\site-packages\django\core\management\__init__.py", line 346, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "c:\srv\venv\dev35\lib\site-packages\django\core\management\base.py", line 394, in run_from_argv
    self.execute(*args, **cmd_options)
  File "c:\srv\venv\dev35\lib\site-packages\django\core\management\base.py", line 445, in execute
    output = self.handle(*args, **options)
  File "c:\users\bjorn\pycharmprojects\django_dramatiq\django_dramatiq\management\commands\rundramatiq.py", line 98, in handle
    tasks_modules = self.discover_tasks_modules()
  File "c:\users\bjorn\pycharmprojects\django_dramatiq\django_dramatiq\management\commands\rundramatiq.py", line 170, in discover_tasks_modules
    if not self._is_package(imported_module):
  File "c:\users\bjorn\pycharmprojects\django_dramatiq\django_dramatiq\management\commands\rundramatiq.py", line 188, in _is_package
    return module_path and os.path.isdir(module_path[0])
TypeError: '_NamespacePath' object does not support indexing

It's coming from an "installed" app that has a tasks directory without an __init__.py (not uncommon in our code base), so it's triggering the Implicit Namespace Packages feature.

In addition tasks.py is also the name used for invoke (http://www.pyinvoke.org/), so it would be great to have a way to override it, e.g. by settings.DJANGO_DRAMATIQ_TASK_MODULE.

I can provide a PR if it would be helpful...?

@Bogdanp
Copy link
Owner

Bogdanp commented May 4, 2021

A PR to add an override would be great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants