Skip to content
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

Merged
merged 4 commits into from
Mar 15, 2018
Merged

0.3.7-rc2 #49

merged 4 commits into from
Mar 15, 2018

Conversation

ograycode
Copy link
Contributor

This does a couple of things:

  1. Makes it so the environment variable ZC_EVENTS_SETTINGS is used first, and django settings is the backup. This was done because JOB_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.

  2. 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.

  3. Updates setup.py file for 0.3.7-rc2.

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.
Copy link
Contributor

@tpilara tpilara left a 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.

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')
Copy link
Contributor

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:
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was fixed.

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:
Copy link
Contributor

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.

@ograycode
Copy link
Contributor Author

We are test driving code climate. It brought up some valid issues, and I'll address them before we drop the release candidate version.

@ograycode ograycode merged commit c926c08 into master Mar 15, 2018
@ograycode ograycode deleted the og/reconfigure-settings branch March 15, 2018 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants