Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


config file option doesn't work for dotted names #154

merged 2 commits into from

2 participants


Due to the way __import__ works (see fourth paragraph) dotted config package / module names are not correctly imported.

The most robust solution would probably be to switch to using importlib.import_module(). importlib is bundled with python from 2.7 onwards and is available on PyPI for older python versions down to 2.3.


You mean we need to change the implementation of this function? I'm happy to accept a patch for it. Make sure to depend on importlib only if Python < 2.7 in


Exactly, thats the place.
I'll put up a pull req' later today.

Edit: I just saw that you already have a conditional dependency on importlib for < 2.7. So the pull request will be very short :)


Hah! That must have been a left-over from the past, which I forgot to remove, then :))

@nvie nvie merged commit a543a38 into from


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
3  rq/scripts/
@@ -1,3 +1,4 @@
+import importlib
import redis
from rq import use_connection
@@ -19,7 +20,7 @@ def add_standard_arguments(parser):
def read_config_file(module):
"""Reads all UPPERCASE variables defined in the given module file."""
- settings = __import__(module, [], [], [], -1)
+ settings = importlib.import_module(module)
return dict([(k, v)
for k, v in settings.__dict__.items()
if k.upper() == k])
1  tests/
@@ -0,0 +1 @@
8 tests/
@@ -0,0 +1,8 @@
+from unittest import TestCase
+from rq.scripts import read_config_file
+class TestScripts(TestCase):
+ def test_config_file(self):
+ settings = read_config_file("tests.dummy_settings")
+ self.assertIn("REDIS_HOST", settings)
+ self.assertEqual(settings['REDIS_HOST'], "")
Something went wrong with that request. Please try again.