Skip to content

Commit 9ecf81c

Browse files
authored
Create test project for huey (#68)
1 parent fe492e2 commit 9ecf81c

5 files changed

Lines changed: 73 additions & 0 deletions

File tree

test-huey/main.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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.")

test-huey/pyproject.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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 }

test-huey/run-consumer.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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

test-huey/run.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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

test-huey/tasks.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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

0 commit comments

Comments
 (0)