-
Notifications
You must be signed in to change notification settings - Fork 2
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
0.3.7-rc2 #49
0.3.7-rc2 #49
Conversation
If using django settings only, and the settings file imports a model, django will fail hard on startup. This could be common scenario for the JOB_MAPPING setting which takes a key of a string and the value is the function to execute. Thus, if the file that the function lives in imports a django model, the app will not be initialized yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good only a few minor comments.
zc_events/config.py
Outdated
self._settings = django_settings | ||
else: | ||
import_path = os.environ.get('ZC_EVENTS_SETTINGS') | ||
if import_path: | ||
logger.debug('zc_events could not use django settings, using ZC_EVENTS_SETTINGS') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This log message reflects the old order of checking settings modules
@@ -54,6 +50,9 @@ def __getattr__(self, name): | |||
) | |||
) | |||
raise e | |||
elif django_settings: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although unlikely, what would happen if import_path
and django_settings
both evaluated to False
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was fixed.
zc_events/config.py
Outdated
logger.debug('zc_events could not use django settings, using ZC_EVENTS_SETTINGS') | ||
import_path = os.environ.get('ZC_EVENTS_SETTINGS') | ||
try: | ||
self._settings = importlib.import_module(import_path) | ||
except Exception as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer this to be a tighter exception catch (I think it would be ImportError
) if possible.
49ec2fc
to
c0c22a7
Compare
We are test driving code climate. It brought up some valid issues, and I'll address them before we drop the release candidate version. |
This does a couple of things:
Makes it so the environment variable
ZC_EVENTS_SETTINGS
is used first, and django settings is the backup. This was done becauseJOB_MAPPING
requires you to import the actual task to run, and that might import a part of the django code that is not ready yet -- leading to an app configuration error.Lazy evaluation of redis and rabbitmq connections so it only happens when needed. These read off settings which may not be available yet, leading to errors.
Updates setup.py file for 0.3.7-rc2.