-
-
Save ask/451126 to your computer and use it in GitHub Desktop.
Revisions
-
ask revised this gist
Jun 24, 2010 . 1 changed file with 31 additions and 22 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,22 +1,31 @@ >>> from tasks import send_emails, process_emails >>> send_emails.delay() <AsyncResult: 4e136dc4-2757-4fce-89a1-4705b5153587> >>> process_emails.delay() <AsyncResult: 600f8117-77e1-43b3-9fb8-ca0988fd335d> [2010-06-24 09:46:04,176: INFO/MainProcess] Got task from broker: tasks.send_emails[c2883ef7-d63e-4060-bd92-883092b50de9] [2010-06-24 09:46:04,287: INFO/MainProcess] Task tasks.send_emails[c2883ef7-d63e-4060-bd92-883092b50de9] processed: None [2010-06-24 09:46:09,590: INFO/MainProcess] Got task from broker: tasks.process_emails[154dcac0-3593-49a0-a7f5-2a5b4aa4f5c0] [2010-06-24 09:46:09,655: WARNING/PoolWorker-2] boo [2010-06-24 09:46:09,656: WARNING/PoolWorker-2] Message: <carrot.backends.pyamqplib.Message object at 0x1022a3750> [2010-06-24 09:46:09,657: WARNING/PoolWorker-2] boo [2010-06-24 09:46:09,657: WARNING/PoolWorker-2] Message: <carrot.backends.pyamqplib.Message object at 0x1022a3950> [2010-06-24 09:46:09,657: WARNING/PoolWorker-2] boo [2010-06-24 09:46:09,658: WARNING/PoolWorker-2] Message: <carrot.backends.pyamqplib.Message object at 0x1022a38d0> [2010-06-24 09:46:09,658: WARNING/PoolWorker-2] boo [2010-06-24 09:46:09,658: WARNING/PoolWorker-2] Message: <carrot.backends.pyamqplib.Message object at 0x1022a39d0> [2010-06-24 09:46:09,659: WARNING/PoolWorker-2] boo [2010-06-24 09:46:09,659: WARNING/PoolWorker-2] Message: <carrot.backends.pyamqplib.Message object at 0x1022a3990> [2010-06-24 09:46:09,660: WARNING/PoolWorker-2] boo [2010-06-24 09:46:09,660: WARNING/PoolWorker-2] Message: <carrot.backends.pyamqplib.Message object at 0x1022a3890> [2010-06-24 09:46:09,661: WARNING/PoolWorker-2] boo [2010-06-24 09:46:09,661: WARNING/PoolWorker-2] Message: <carrot.backends.pyamqplib.Message object at 0x1022a3910> [2010-06-24 09:46:09,661: WARNING/PoolWorker-2] boo [2010-06-24 09:46:09,661: WARNING/PoolWorker-2] Message: <carrot.backends.pyamqplib.Message object at 0x1022a3750> [2010-06-24 09:46:09,662: WARNING/PoolWorker-2] boo [2010-06-24 09:46:09,662: WARNING/PoolWorker-2] Message: <carrot.backends.pyamqplib.Message object at 0x1022a3950> [2010-06-24 09:46:09,663: WARNING/PoolWorker-2] boo [2010-06-24 09:46:09,663: WARNING/PoolWorker-2] Message: <carrot.backends.pyamqplib.Message object at 0x1022a38d0> [2010-06-24 09:46:09,679: INFO/MainProcess] Task tasks.process_emails[154dcac0-3593-49a0-a7f5-2a5b4aa4f5c0] processed: None -
ask revised this gist
Jun 24, 2010 . 1 changed file with 22 additions and 22 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,26 +1,26 @@ 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: for i in xrange(n): pub.send({"e-mail": "[email protected]"}) finally: pub.close() conn.close() @task() def process_emails(): conn = send_emails.establish_connection() consumer = Consumer(conn, queue="sendemail", exchange="sendemail", routing_key="sendemail_emails") for message in consumer.iterqueue(): print("boo") print("Message: %s" % (message, )) message.ack() -
markhellewell renamed this gist
Jun 24, 2010 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
markhellewell revised this gist
Jun 24, 2010 . 1 changed file with 22 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ from carrot.connection import DjangoBrokerConnection from carrot.messaging import Publisher, Consumer connection = DjangoBrokerConnection() publisher = Publisher(connection=connection, exchange="sendemail", routing_key="sendemail_emails") publisher.send({'email': '[email protected]'}) publisher.send({'email': '[email protected]'}) publisher.send({'email': '[email protected]'}) publisher.send({'email': '[email protected]'}) publisher.send({'email': '[email protected]'}) publisher.send({'email': '[email protected]'}) publisher.send({'email': '[email protected]'}) publisher.send({'email': '[email protected]'}) publisher.send({'email': '[email protected]'}) publisher.send({'email': '[email protected]'}) publisher.send({'email': '[email protected]'}) publisher.send({'email': '[email protected]'}) publisher.send({'email': '[email protected]'}) publisher.send({'email': '[email protected]'}) publisher.send({'email': '[email protected]'}) publisher.send({'email': '[email protected]'}) publisher.close() connection.close() -
markhellewell revised this gist
Jun 24, 2010 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -16,9 +16,9 @@ then in my Celery Task: try: connection = DjangoBrokerConnection() consumer = Consumer(connection=connection, queue="sendemail", exchange="sendemail", routing_key="sendemail_emails") logger.info("sending emails...") for message in consumer.iterqueue(): -
markhellewell created this gist
Jun 24, 2010 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ if request.method == "POST": email_form = SendAnEmail(request.POST, prefix='emailform') if email_form.is_valid(): connection = DjangoBrokerConnection() publisher = Publisher(connection=connection, exchange="sendemail", routing_key="sendemail_emails") publisher.send(email_form.cleaned_data.get('email_address')) publisher.close() connection.close() then in my Celery Task: try: connection = DjangoBrokerConnection() consumer = Consumer(connection=connection, queue="senddrop", exchange="senddrop", routing_key="senddrop_emails") logger.info("sending emails...") for message in consumer.iterqueue(): logger.info("boo") logger.info(message.payload.get('email'))