Skip to content

Instantly share code, notes, and snippets.

View ask's full-sized avatar
🎯
Focusing

Ask Solem ask

🎯
Focusing
View GitHub Profile
@ask
ask / async.py
Last active August 29, 2015 14:01 — forked from mikeywaites/async.py
#project.async
from celery import Celery
celery = Celery(autofinalize=False)
def configure_celery(flask_app):
#...set celery up
celery.config_from_object(app.config)
#!/usr/bin/env python
import logging
from pika import BlockingConnection, ConnectionParameters
if __name__ == '__main__':
logging.basicConfig(level=logging.INFO)
@ask
ask / gist:1834966
Created February 15, 2012 10:43 — forked from sleekslush/gist:1828464
-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.
import eventlet
from eventlet import wsgi
from eventlet import sleep
def switch(it):
for item in it:
yield item
sleep(0.0)
@ask
ask / get_results.py
Created June 22, 2011 17:37 — forked from lrvick/get_results.py
Get async celery results from subtasks
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 = []
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:
"""
Consumer
--------
>>> import ericflopsy
>>> conn = ericflopsy.Connection()
>>> consumer = ericflopsy.Consumer(connection=conn)
>>> def print_message(message_body, message):
... print 'Recieved: ' + message_body
... message.ack()