-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move scripts into their own isolated package.
- Loading branch information
Showing
8 changed files
with
57 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,3 @@ def launch(): | |
if not config.ready: | ||
config.load() | ||
scheduler.start() | ||
|
||
|
||
if __name__ == '__main__': | ||
launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,9 @@ | ||
"""Heroku web worker.""" | ||
# Make sure gevent patches are applied early. | ||
import os | ||
|
||
listen = ['high', 'default', 'low'] | ||
|
||
|
||
def main(): | ||
import gevent.monkey | ||
gevent.monkey.patch_all() | ||
|
||
# These imports are inside the __main__ block | ||
# to make sure that we only import from rq_gevent_worker | ||
# (which has the side effect of applying gevent monkey patches) | ||
# in the worker process. This way other processes can import the | ||
# redis connection without that side effect. | ||
from rq import ( | ||
Queue, | ||
Connection | ||
) | ||
from dallinger.db import redis_conn | ||
from dallinger.heroku.rq_gevent_worker import GeventWorker as Worker | ||
|
||
from dallinger.config import initialize_experiment_package | ||
initialize_experiment_package(os.getcwd()) | ||
|
||
import logging | ||
logging.basicConfig(format='%(asctime)s %(message)s', level=logging.DEBUG) | ||
|
||
with Connection(redis_conn): | ||
worker = Worker(list(map(Queue, listen))) | ||
worker.work() | ||
|
||
|
||
if __name__ == '__main__': # pragma: nocover | ||
main() | ||
else: | ||
import warnings | ||
warnings.warn( | ||
u"Importing from heroku.worker is deprecated and may cause errors." | ||
u"The redis `conn` should be imported from `dallinger.db.redis_conn`", | ||
DeprecationWarning | ||
) | ||
from dallinger.db import redis_conn | ||
|
||
conn = redis_conn | ||
import warnings | ||
from dallinger.db import redis_conn | ||
warnings.warn( | ||
u"Importing from heroku.worker is deprecated and may cause errors." | ||
u"The redis `conn` should be imported from `dallinger.db.redis_conn`", | ||
DeprecationWarning | ||
) | ||
|
||
conn = redis_conn |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
def main(): | ||
from dallinger.heroku.clock import launch | ||
launch() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"""Heroku web worker.""" | ||
# Make sure gevent patches are applied early. | ||
import os | ||
|
||
listen = ['high', 'default', 'low'] | ||
|
||
|
||
def main(): | ||
import gevent.monkey | ||
gevent.monkey.patch_all() | ||
|
||
# These imports are inside the __main__ block | ||
# to make sure that we only import from rq_gevent_worker | ||
# (which has the side effect of applying gevent monkey patches) | ||
# in the worker process. This way other processes can import the | ||
# redis connection without that side effect. | ||
from rq import ( | ||
Queue, | ||
Connection | ||
) | ||
from dallinger.db import redis_conn | ||
from dallinger.heroku.rq_gevent_worker import GeventWorker as Worker | ||
|
||
from dallinger.config import initialize_experiment_package | ||
initialize_experiment_package(os.getcwd()) | ||
|
||
import logging | ||
logging.basicConfig(format='%(asctime)s %(message)s', level=logging.DEBUG) | ||
|
||
with Connection(redis_conn): | ||
worker = Worker(list(map(Queue, listen))) | ||
worker.work() | ||
|
||
|
||
if __name__ == '__main__': # pragma: nocover | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters