Distributing Python with Celery and Redis

The following is a simple application that uses Redis as a broker, where consumer.py sends messages to producer.py. Both the consumer and the producer require this configuration, where you can use the database with number 0 of your local Redis installation:

app = Celery (‘celery_tasks',broker='redis://localhost:6379/0',backend='redis://localhost:6379/0')

To establish a connection with Celery, we need to set broker and backend parameters. The broker parameter allows specification of the server address, where the tasks are stored and the backend parameter is the address where Celery puts the results so that we can use them in our application. In this case, both addresses are the same, executing in localhost ...

Get Learning Python Networking - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.