Skip to content
This repository has been archived by the owner on Jan 11, 2021. It is now read-only.

_frozen_importlib._DeadlockError: deadlock detected by _ModuleLock('django.test.signals') #803

Open
anthonygoslar opened this issue Jun 4, 2019 · 3 comments

Comments

@anthonygoslar
Copy link

I've been writing some signals for a Django project
Django==2.2
Python==3.6.8
PostgreSQL==11.3

After writing and testing some pre_save and post_save signals which update product cart totals based on products inputted, I sometimes get a frozen import DeadLockError (terminal readout below'. Tracing it back, it seems to be occurring with swagger urls. I commented out the swagger urls in my project urls file and the error disappears.

The signals are not a part of any models currently serialized by Django-Restful-Framework. I'll be developing the API at a later stage.

Any ideas what may be causing this?

`Watching for file changes with StatReloader
Performing system checks...

Traceback (most recent call last):
File "manage.py", line 15, in
execute_from_command_line(sys.argv)
File "/Users/username/.pyenv/versions/project/lib/python3.6/site-packages/django/core/management/init.py", line 381, in execute_from_command_line
utility.execute()
File "/Users/username/.pyenv/versions/project/lib/python3.6/site-packages/django/core/management/init.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/username/.pyenv/versions/project/lib/python3.6/site-packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/username/.pyenv/versions/project/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 60, in execute
super().execute(*args, **options)
File "/Users/username/.pyenv/versions/project/lib/python3.6/site-packages/django/core/management/base.py", line 364, in execute
output = self.handle(*args, **options)
File "/Users/username/.pyenv/versions/project/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 95, in handle
self.run(**options)
File "/Users/username/.pyenv/versions/project/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "/Users/username/.pyenv/versions/project/lib/python3.6/site-packages/django/utils/autoreload.py", line 579, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "/Users/username/.pyenv/versions/project/lib/python3.6/site-packages/django/utils/autoreload.py", line 564, in start_django
reloader.run(django_main_thread)
File "/Users/username/.pyenv/versions/project/lib/python3.6/site-packages/django/utils/autoreload.py", line 272, in run
get_resolver().urlconf_module
File "/Users/username/.pyenv/versions/project/lib/python3.6/site-packages/django/utils/functional.py", line 80, in get
res = instance.dict[self.name] = self.func(instance)
File "/Users/username/.pyenv/versions/project/lib/python3.6/site-packages/django/urls/resolvers.py", line 564, in urlconf_module
return import_module(self.urlconf_name)
File "/Users/username/.pyenv/versions/project/lib/python3.6/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 955, in _find_and_load_unlocked
File "", line 665, in _load_unlocked
File "", line 678, in exec_module
File "", line 219, in _call_with_frames_removed
File "/Users/username/workspace/project/backend/src/project/urls.py", line 6, in
from rest_framework_swagger.views import get_swagger_view
File "/Users/username/.pyenv/versions/project/lib/python3.6/site-packages/rest_framework_swagger/views.py", line 3, in
from rest_framework.renderers import CoreJSONRenderer
File "/Users/username/.pyenv/versions/project/lib/python3.6/site-packages/rest_framework/renderers.py", line 20, in
from django.test.client import encode_multipart
File "/Users/username/.pyenv/versions/project/lib/python3.6/site-packages/django/test/client.py", line 23, in
from django.test import signals
File "", line 968, in _find_and_load
File "", line 149, in enter
File "", line 94, in acquire
_frozen_importlib._DeadlockError: deadlock detected by _ModuleLock('django.test.signals') at 4728136760`

@anthonygoslar anthonygoslar changed the title Froe _frozen_importlib._DeadlockError: deadlock detected by _ModuleLock('django.test.signals') Jun 4, 2019
@feruzoripov
Copy link

Try remove pycache folders in all directories and restart virtualenv. It worked for me.

@bennett-jacob
Copy link

@feruzoripov this is not a solution.

@miokyuk
Copy link

miokyuk commented Dec 8, 2020

I have the same error. may be some object get the threading locker but dont release.
In my project, I use apscheduler to run interval job (interval 30s), use SQLAchemy as the jobstore. when shutdown the server for a moment(>60s,a job should run if not shutdown),then restart appear that error. I delete that cron job info in database, its ok.
I dont konw how to solve it.

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

No branches or pull requests

4 participants