Last active
August 1, 2022 10:49
-
-
Save itsjef/f040516fb154984dc15e57e4eb74b04a to your computer and use it in GitHub Desktop.
Revisions
-
itsjef revised this gist
Aug 1, 2022 . 1 changed file with 2 additions and 2 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 @@ -7,11 +7,11 @@ $ docker run --rm -d -p 5672:5672 rabbitmq:3 Then, in 3 different shells, run: ```bash $ celery -A receiver worker -Q in -n receiver -l INFO ``` ```bash $ celery -A sender worker -Q out -n sender -l INFO ``` ```bash -
itsjef revised this gist
Aug 1, 2022 . No changes.There are no files selected for viewing
-
itsjef created this gist
Aug 1, 2022 .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,19 @@ Start RabbitMQ with Docker: ```bash $ docker run --rm -d -p 5672:5672 rabbitmq:3 ``` Then, in 3 different shells, run: ```bash $ celery -A receiver worker -Q in -n in -l INFO ``` ```bash $ celery -A sender worker -Q out -n out -l INFO ``` ```bash $ python sender.py 1 2 3 4 ``` 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,14 @@ from celery import Celery app = Celery(__name__, broker="amqp://localhost") @app.task def calculate_result(x, y): result = x+y app.send_task( "sender.print_result", args=(result,), queue="out" ) 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,18 @@ import sys from celery import Celery app = Celery(__name__, broker="amqp://localhost") @app.task def print_result(v): print(v) if __name__ == "__main__": x, y, *_ = sys.argv[1:] app.send_task( "receiver.calculate_result", args=(float(x), float(y)), queue="in" )