I have Django application running on dokku and keep getting an rq import error message once I link the postgresql database to the dokku app. I do not understand why I am getting this error now, as I have documented the steps I took to deploy this app in the past, and I followed them exactly to deploy it again.
I deploy my dokku app, then I get blue screened because it relies on redis and postgres. From there I link redis, which does not show an error on redeploy. Then I link my new postgres database and it throws the following error:
20:12:02 system | web.1 started (pid=31)
20:12:02 system | default_worker.1 started (pid=35)
20:12:02 system | archive_expired_jobs.1 started (pid=37)
20:12:02 system | badgr_sync.1 started (pid=41)
20:12:08 default_worker.1 | Traceback (most recent call last):
20:12:08 default_worker.1 | File "manage.py", line 22, in <module>
20:12:08 default_worker.1 | main()
20:12:08 default_worker.1 | File "manage.py", line 18, in main
20:12:08 default_worker.1 | execute_from_command_line(sys.argv)
20:12:08 default_worker.1 | File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
20:12:08 default_worker.1 | utility.execute()
20:12:08 default_worker.1 | File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 395, in execute
20:12:08 default_worker.1 | self.fetch_command(subcommand).run_from_argv(self.argv)
20:12:08 default_worker.1 | File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 244, in fetch_command
20:12:08 default_worker.1 | klass = load_command_class(app_name, subcommand)
20:12:08 default_worker.1 | File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 37, in load_command_class
20:12:08 default_worker.1 | module = import_module('%s.management.commands.%s' % (app_name, name))
20:12:08 default_worker.1 | File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
20:12:08 default_worker.1 | File "<frozen importlib._bootstrap>", line 994, in _gcd_import
20:12:08 default_worker.1 | File "<frozen importlib._bootstrap>", line 971, in _find_and_load
20:12:08 default_worker.1 | File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
20:12:08 default_worker.1 | File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
20:12:08 default_worker.1 | File "<frozen importlib._bootstrap_external>", line 678, in exec_module
20:12:08 default_worker.1 | File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
20:12:08 default_worker.1 | File "/usr/local/lib/python3.6/dist-packages/django_rq/management/commands/rqworker.py", line 6, in <module>
20:12:08 default_worker.1 | from rq import use_connection
20:12:08 default_worker.1 | ImportError: cannot import name 'use_connection'
20:12:08 system | default_worker.1 stopped (rc=1)
20:12:08 system | sending SIGTERM to web.1 (pid 31)
20:12:08 system | sending SIGTERM to archive_expired_jobs.1 (pid 37)
20:12:08 system | sending SIGTERM to badgr_sync.1 (pid 41)
20:12:08 system | archive_expired_jobs.1 stopped (rc=-15)
20:12:08 system | badgr_sync.1 stopped (rc=-15)
20:12:08 system | web.1 stopped (rc=-15)
=====> End uwf-server (f353df3ecff8) container output
-----> Checking for postdeploy task
No postdeploy task found, skipping
-----> Shutting down old containers in 60 seconds
=====> Application deployed:
http://3.23.111.72
I am completely dumbfounded. This application is running with the exact same code and dockerfile on another EC2 instance and I have stood it up before using the same exact steps. Django-rq is also in the requirements.txt folder so I know its being added to the environments.
2
Answers
Django rq use connection depreciated in a recent update. To fix the issue I had to update my Django rq version to 2.8.0
This is because
django-rq
installsrq
as a dependency, anddjango-rq
tries to import the deprecated functionuse_connection
from the rq library, which then results in this error.To make it work, either upgrade
django-rq
to 2.8.0 or add the following in your requirements file:rq==1.13.0
This would pin
rq
to a version for which the function is still supported, and hence you would see no errors.