This file contains hidden or 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
#project.async | |
from celery import Celery | |
celery = Celery(autofinalize=False) | |
def configure_celery(flask_app): | |
#...set celery up | |
celery.config_from_object(app.config) | |
This file contains hidden or 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
#!/usr/bin/env python | |
import logging | |
from pika import BlockingConnection, ConnectionParameters | |
if __name__ == '__main__': | |
logging.basicConfig(level=logging.INFO) |
This file contains hidden or 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
-When I'm configuring in a Django app, what is the purpose of the djcelery models? Right --now tables get created, but nothing flows into them. Is this the database backend | |
---- replacement for Redis and RabbitMQ? Or is it something else? | |
- Several database tables are used: | |
* Monitoring | |
When you use the django-admin monitor the cluster state is written | |
to the TaskState and WorkerState tables. |
This file contains hidden or 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
import eventlet | |
from eventlet import wsgi | |
from eventlet import sleep | |
def switch(it): | |
for item in it: | |
yield item | |
sleep(0.0) |
This file contains hidden or 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
from tasks import task1 | |
from celery.task import TaskSet | |
from celery.result import AsyncResult, ResultSet | |
def get_results(queries): | |
query_procs = task1.delay(queries).get().join() | |
results = [] |
This file contains hidden or 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
from carrot.connection import BrokerConnection | |
from carrot.messaging import Consumer, Publisher | |
@task() | |
def send_emails(n=10): | |
conn = send_emails.establish_connection() | |
pub = Publisher(conn, exchange="sendemail", | |
routing_key="sendemail_emails") | |
try: |
This file contains hidden or 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
""" | |
Consumer | |
-------- | |
>>> import ericflopsy | |
>>> conn = ericflopsy.Connection() | |
>>> consumer = ericflopsy.Consumer(connection=conn) | |
>>> def print_message(message_body, message): | |
... print 'Recieved: ' + message_body | |
... message.ack() |