Permalink
Browse files

Merge pull request #17 from hichenming/master

auto register tasks, and fix server bugs
  • Loading branch information...
mher committed Aug 16, 2013
2 parents 3dc655c + 8c6c30a commit e1e2e5f4298f65380a3d7a1b405dc61639bb0c72
Showing with 11 additions and 4 deletions.
  1. +1 −1 README.rst
  2. +2 −1 tcelery/__init__.py
  3. +8 −2 tcelery/__main__.py
View
@@ -36,7 +36,7 @@ Calling tasks with generator-based interface: ::
tornado-celery can be launched as a web server: ::
- $ python -m tcelery --port=8888
+ $ python -m tcelery --port=8888 --app=proj.celery:celery --address=0.0.0.0
Execute a task asynchronously: ::
View
@@ -21,7 +21,8 @@ def setup_nonblocking_producer(celery_app=None, io_loop=None,
NonBlockingTaskProducer.app = celery_app
NonBlockingTaskProducer.conn_pool = ConnectionPool(limit=limit)
NonBlockingTaskProducer.result_cls = result_cls
- celery.app.amqp.AMQP.producer_cls = NonBlockingTaskProducer
+ if celery_app.conf['BROKER_URL'] and celery_app.conf['BROKER_URL'].startswith('amqp'):
+ celery.app.amqp.AMQP.producer_cls = NonBlockingTaskProducer
def connect():
broker_url = celery_app.connection().as_uri(include_password=True)
View
@@ -12,9 +12,11 @@
from .app import Application
from . import setup_nonblocking_producer
+from celery.loaders.base import BaseLoader
-define("port", default=8888, type=bool, help="run on the given port")
+define("port", default=8888, type=int, help="run on the given port")
+define("address", default='127.0.0.1', type=str, help="the bind address")
class TCeleryCommand(Command):
@@ -25,7 +27,11 @@ def run_from_argv(self, prog_name, argv=None):
logging.info("Starting http server on port %s..." % options.port)
http_server = httpserver.HTTPServer(Application(celery_app=self.app))
- http_server.listen(options.port)
+ http_server.listen(options.port, options.address)
+
+ bloader = BaseLoader()
+ bloader.import_default_modules()
+
logging.info("Registered tasks:")
logging.info(pformat(self.app.tasks.keys()))

0 comments on commit e1e2e5f

Please sign in to comment.