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

AppRegistryNotReady Exception on Django 1.10 Dev #164

Closed
dacodekid opened this issue Apr 14, 2016 · 9 comments
Closed

AppRegistryNotReady Exception on Django 1.10 Dev #164

dacodekid opened this issue Apr 14, 2016 · 9 comments

Comments

@dacodekid
Copy link

When running ./manage.py migrate on Django 1.10.dev20160413172854 throws the following exception. But changing to Django 1.9.5 works fine. Is there any fix to work with dev version?

╰─$ ./manage.py migrate
Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/dacodekid/dev/django/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/Users/dacodekid/dev/django/django/core/management/__init__.py", line 341, in execute
    django.setup()
  File "/Users/dacodekid/dev/django/django/__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Users/dacodekid/dev/django/django/apps/registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "/Users/dacodekid/dev/django/django/apps/config.py", line 90, in create
    module = import_module(entry)
  File "/Users/dacodekid/.envs/tradex/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 662, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/Users/dacodekid/.envs/tradex/lib/python3.5/site-packages/django_q/__init__.py", line 15, in <module>
    from .tasks import async, schedule, result, result_group, fetch, fetch_group, count_group, delete_group, queue_size
  File "/Users/dacodekid/.envs/tradex/lib/python3.5/site-packages/django_q/tasks.py", line 11, in <module>
    import cluster
  File "/Users/dacodekid/.envs/tradex/lib/python3.5/site-packages/django_q/cluster.py", line 31, in <module>
    import tasks
  File "/Users/dacodekid/.envs/tradex/lib/python3.5/site-packages/django_q/tasks.py", line 13, in <module>
    from django_q.models import Schedule, Task
  File "/Users/dacodekid/.envs/tradex/lib/python3.5/site-packages/django_q/models.py", line 12, in <module>
    class Task(models.Model):
  File "/Users/dacodekid/dev/django/django/db/models/base.py", line 94, in __new__
    app_config = apps.get_containing_app_config(module)
  File "/Users/dacodekid/dev/django/django/apps/registry.py", line 239, in get_containing_app_config
    self.check_apps_ready()
  File "/Users/dacodekid/dev/django/django/apps/registry.py", line 124, in check_apps_ready
    raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
@carltongibson
Copy link

I wonder if it's caused by this:

Apps registry is no longer auto-populated when unpickling models outside of Django

The apps registry is no longer auto-populated when unpickling models. This was added in Django 1.7.2 as an attempt to allow unpickling models outside of Django, such as in an RQ worker, without calling django.setup(), but it creates the possibility of a deadlock. To adapt your code in the case of RQ, you can provide your own worker script that calls django.setup().

— Django 1.10 Release Notes

@Koed00
Copy link
Owner

Koed00 commented Apr 14, 2016

I'll try to have a look at this in the weekend.
@carltongibson is probably right, but I need to make sure it doesn't break compatibility with the older Django versions. I try to to support the last two major (released) versions of Django.

@Koed00
Copy link
Owner

Koed00 commented Apr 24, 2016

I'm going to postpone this until the 1.10 alpha is released in about two weeks.

@techdragon
Copy link

techdragon commented May 15, 2016

I've just run into this with a Django 1.9.6 site, so this doesn't appear to be just a 1.10.x issue.

Edit 1: Never mind. - I suspect this may be a case of shooting off my own foot. I was trying to write a little check function to warn me if the django-q cluster wasn't running when doing local development. I suspect the blame for the AppRegistryNotReady exception is mine.

@Koed00
Copy link
Owner

Koed00 commented May 15, 2016

I've updated the tests to 1.9.6. I wouldn't be the first time that some of Django's next releases code ended up in an earlier version through a bugfix.
Still a bit until the 1.10 alpha is released and I can start testing that.

@Koed00
Copy link
Owner

Koed00 commented Jun 7, 2016

It turned out to be a problem with the code that makes Django 1.8 and lower work.
I've adjusted the code to allow for 1.10 versions.
Also optparse is now deprecated, so I replaced that with argparse for the commands.

Should work on 1.10a1. Tests are passing on Travis.

@thinkwelltwd
Copy link

It turned out to be a problem with the code that makes Django 1.8 and lower work.

Does your fix still allow Django 1.8 to work? I have to be on the LTS till the next LTS release.

@Eagllus
Copy link
Collaborator

Eagllus commented Feb 6, 2018

@thinkwelltwd could you confirm that this issue can be closed?

@thinkwelltwd
Copy link

Yes it can as far as I know. I'm now on 1.11 so I'm not using older versions.

@Eagllus Eagllus closed this as completed Feb 7, 2018
P-EB pushed a commit to P-EB/django-q that referenced this issue Oct 20, 2024
* Add index on task table

* also add models file

* add make commands and limit index

* format
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

6 participants