3

I am getting this error when I go for python manage.py runserver

error - 
    _frozen_importlib._DeadlockError: deadlock detected by _ModuleLock('django.test.signals') at 140668266856120

Please help me out. I saw other questions but it says that same model is called multiple times or same database table has been called multiple times.

Santosh Aryal
  • 1,276
  • 1
  • 18
  • 41
Gaurav Gupta
  • 405
  • 7
  • 23
  • as a test, did you remove migration files in your project? just remember that never don't remove __init__.py files in migration folders – Erfan Dec 29 '19 at 07:11
  • Yes, I tried after removing migrations files while init.py file was kept intact. But this didnt resolve the problem. – Gaurav Gupta Dec 30 '19 at 07:01
  • I made another project and another app separately with the same code, it worked. I dont know exactly...... why it is so. I t works with the same code but in different app and project at the same location. ( Just for the reference) – Gaurav Gupta Dec 30 '19 at 07:02
  • 1
    if you are using virtual environment, just remove your venv and created another again. – Erfan Dec 31 '19 at 06:26
  • Okk... Let me check @Erfan37 – Gaurav Gupta Mar 23 '20 at 08:22

2 Answers2

1

You can fix this by upgrading your Django version to 2.2.24 like this:

pip install --upgrade django==2.2.24
Reza Rahemtola
  • 1,182
  • 7
  • 16
  • 30
0

So this issue is likely as a result of a circular import - that is, in one module you have imported one module, and in that module you have imported the other.

Such as:

Inside notifications/serializers.py:

from books.serializers import BookSerializer

And inside books/serializers.py:

from notifications.serializers import NotificationSerializer

Hence, this causes a deadlock error...and it is very hard to pinpoint the circular import because it won't tell you where this circular import has occured.

Micheal J. Roberts
  • 3,735
  • 4
  • 37
  • 76