Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
ecommerce-worker
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
ecommerce-worker
Commits
13560b50
Commit
13560b50
authored
Jan 06, 2016
by
Renzo Lucioni
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7 from edx/renzo/avoid-accidental-initialization
Avoid initialization of Celery when used as a package
parents
4a282047
6e4dd1aa
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
7 deletions
+14
-7
ecommerce_worker/celery_app.py
+3
-4
ecommerce_worker/configuration/__init__.py
+6
-0
ecommerce_worker/fulfillment/v1/tests/test_tasks.py
+2
-0
ecommerce_worker/utils.py
+2
-2
setup.py
+1
-1
No files found.
ecommerce_worker/celery_app.py
View file @
13560b50
import
os
import
os
from
celery
import
Celery
from
celery
import
Celery
from
ecommerce_worker.configuration
import
CONFIGURATION_MODULE
# Environment variable indicating which configuration module to use.
CONFIGURATION
=
'WORKER_CONFIGURATION_MODULE'
# Set the default configuration module, if one is not aleady defined.
# Set the default configuration module, if one is not aleady defined.
os
.
environ
.
setdefault
(
CONFIGURATION
,
'ecommerce_worker.configuration.local'
)
os
.
environ
.
setdefault
(
CONFIGURATION
_MODULE
,
'ecommerce_worker.configuration.local'
)
app
=
Celery
(
'ecommerce_worker'
)
app
=
Celery
(
'ecommerce_worker'
)
# See http://celery.readthedocs.org/en/latest/userguide/application.html#config-from-envvar.
# See http://celery.readthedocs.org/en/latest/userguide/application.html#config-from-envvar.
app
.
config_from_envvar
(
CONFIGURATION
)
app
.
config_from_envvar
(
CONFIGURATION
_MODULE
)
ecommerce_worker/configuration/__init__.py
View file @
13560b50
import
os
import
os
# Environment variable indicating which configuration module to use
# when running the worker.
CONFIGURATION_MODULE
=
'WORKER_CONFIGURATION_MODULE'
def
get_overrides_filename
(
variable
):
def
get_overrides_filename
(
variable
):
"""
"""
Get the name of the file containing configuration overrides
Get the name of the file containing configuration overrides
...
...
ecommerce_worker/fulfillment/v1/tests/test_tasks.py
View file @
13560b50
...
@@ -9,6 +9,8 @@ import httpretty
...
@@ -9,6 +9,8 @@ import httpretty
import
jwt
import
jwt
import
mock
import
mock
# Ensures that a Celery app is initialized when tests are run.
from
ecommerce_worker
import
celery_app
# pylint: disable=unused-import
from
ecommerce_worker.fulfillment.v1.tasks
import
fulfill_order
from
ecommerce_worker.fulfillment.v1.tasks
import
fulfill_order
from
ecommerce_worker.utils
import
get_configuration
from
ecommerce_worker.utils
import
get_configuration
...
...
ecommerce_worker/utils.py
View file @
13560b50
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
import
os
import
os
import
sys
import
sys
from
ecommerce_worker.c
elery_app
import
CONFIGURATION
from
ecommerce_worker.c
onfiguration
import
CONFIGURATION_MODULE
def
get_configuration
(
variable
):
def
get_configuration
(
variable
):
...
@@ -17,7 +17,7 @@ def get_configuration(variable):
...
@@ -17,7 +17,7 @@ def get_configuration(variable):
Returns:
Returns:
The value corresponding to the variable, or None if the variable is not found.
The value corresponding to the variable, or None if the variable is not found.
"""
"""
name
=
os
.
environ
.
get
(
CONFIGURATION
)
name
=
os
.
environ
.
get
(
CONFIGURATION
_MODULE
)
# __import__ performs a full import, but only returns the top-level
# __import__ performs a full import, but only returns the top-level
# package, not the targeted module. sys.modules is a dictionary
# package, not the targeted module. sys.modules is a dictionary
...
...
setup.py
View file @
13560b50
...
@@ -6,7 +6,7 @@ with open('README.rst') as readme:
...
@@ -6,7 +6,7 @@ with open('README.rst') as readme:
setup
(
setup
(
name
=
'edx-ecommerce-worker'
,
name
=
'edx-ecommerce-worker'
,
version
=
'0.
2
.0'
,
version
=
'0.
3
.0'
,
description
=
'Celery tasks supporting the operations of edX
\'
s ecommerce service'
,
description
=
'Celery tasks supporting the operations of edX
\'
s ecommerce service'
,
long_description
=
long_description
,
long_description
=
long_description
,
classifiers
=
[
classifiers
=
[
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment