File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ from tasks import add_numbers , divide
2+
3+ if __name__ == "__main__" :
4+ print ("Enqueuing tasks..." )
5+ add_numbers (3 , 7 )
6+ divide (10 , 2 )
7+ divide (1 , 0 )
8+ print ("Tasks enqueued. Run the consumer to process them." )
Original file line number Diff line number Diff line change 1+ [project ]
2+ name = " test-huey"
3+ version = " 0"
4+ requires-python = " >=3.12"
5+
6+ dependencies = [
7+ " huey>=2.0" ,
8+ " ipdb>=0.13.13" ,
9+ " redis>=5.2.1" ,
10+ " sentry-sdk" ,
11+ ]
12+
13+ [tool .uv .sources ]
14+ sentry-sdk = { path = " ../../sentry-python" , editable = true }
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -euo pipefail
3+ reset
4+
5+ if ! command -v uv & > /dev/null; then
6+ curl -LsSf https://astral.sh/uv/install.sh | sh
7+ fi
8+
9+ pkill redis-server || true
10+ sleep 1
11+ rm -rf dump.rdb
12+ redis-server --daemonize yes
13+
14+ uv run huey_consumer tasks.huey --workers 1
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -euo pipefail
3+ reset
4+
5+ if ! command -v uv & > /dev/null; then
6+ curl -LsSf https://astral.sh/uv/install.sh | sh
7+ fi
8+
9+ uv run python main.py
Original file line number Diff line number Diff line change 1+ import os
2+
3+ from huey import RedisHuey
4+
5+ import sentry_sdk
6+ from sentry_sdk .integrations .huey import HueyIntegration
7+
8+ sentry_sdk .init (
9+ dsn = os .environ .get ("SENTRY_DSN" ),
10+ environment = os .environ .get ("ENV" , "test" ),
11+ traces_sample_rate = 1.0 ,
12+ debug = True ,
13+ integrations = [
14+ HueyIntegration (),
15+ ],
16+ )
17+
18+ huey = RedisHuey ("test-huey" , host = "localhost" , port = 6379 )
19+
20+
21+ @huey .task ()
22+ def add_numbers (a , b ):
23+ return a + b
24+
25+
26+ @huey .task (retries = 1 )
27+ def divide (a , b ):
28+ return a / b
You can’t perform that action at this time.
0 commit comments