Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

class Config(BaseSettings):
app_name: str = "celery"
redis_url: str = "redis://localhost:6379/0"
redis_broker_url: str = "redis://localhost:6379/15"
redis_beat_url: str = "redis://localhost:6379/14"


config = Config()
4 changes: 2 additions & 2 deletions background.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from tasks.hello import hello
from tasks.welcome import welcome

app = Celery("sidekick", broker=config.redis_url, backend="rpc://")
app = Celery("sidekick", broker=config.redis_broker_url, backend="rpc://")
app.config_from_object("celery_config")

# tasks
Expand All @@ -17,4 +17,4 @@


if __name__ == "__main__":
[(hi.delay(2), hello.delay(2), bye.delay(2), welcome.delay(2)) for i in range(1000)]
[(hi.delay(2), hello.delay(2), bye.delay(2), welcome.delay(2)) for i in range(500)]
10 changes: 9 additions & 1 deletion celery_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import redbeat
from Config import config
from kombu import Exchange, Queue


CELERY_QUEUES = (
broker_heartbeat = 10
redbeat_lock_timeout = 60
beat_max_loop_interval = 10
redbeat_redis_url = config.redis_beat_url
beat_scheduler = f"{redbeat.__name__}.{redbeat.RedBeatScheduler.__name__}"

task_queues = (
Queue("hi", Exchange("hi"), routing_key="hi"),
Queue("bye", Exchange("bye"), routing_key="bye"),
Queue("hello", Exchange("hello"), routing_key="hello"),
Expand Down
11 changes: 0 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
version: '3'

services:
db:
container_name: db
image: postgres
restart: always
environment:
DB: celery
DB_USER: celery
DB_PASSWORD: celery
ports:
- 5432:5432

redis:
container_name: redis
image: redis:latest
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ python-dotenv==1.0.0
pydantic==2.5.2
pydantic-settings==2.1.0
SQLAlchemy==2.0.23
psycopg2==2.9.9
# psycopg2==2.9.9
celery-redbeat==2.1.1