Skip to content

Commit 1b8d8e4

Browse files
chrisguidryclaude
andcommitted
Fix Python 3.10 compatibility and chaos driver NOGROUP handling
- Replace asyncio.TaskGroup with asyncio.gather for Python 3.10 compat - Handle NOGROUP errors in chaos driver when workers haven't started yet 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent b83292c commit 1b8d8e4

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

chaos/driver.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,13 @@ async def spawn_worker() -> Process:
246246
"driver: Redis connection error (%s), retrying in 5s...", e
247247
)
248248
await asyncio.sleep(5)
249+
except redis.exceptions.ResponseError as e:
250+
if "NOGROUP" in str(e):
251+
# Consumer group not created yet, workers haven't started
252+
logger.debug("driver: Consumer group not yet created, waiting...")
253+
await asyncio.sleep(1)
254+
else:
255+
raise
249256

250257
# Now apply some chaos to the system:
251258

tests/test_worker.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,12 +1049,10 @@ async def counting_task(worker: Worker = CurrentWorker()):
10491049
for _ in range(5)
10501050
]
10511051

1052-
async with asyncio.TaskGroup() as tg:
1053-
for w in workers:
1054-
await w.__aenter__()
1052+
for w in workers:
1053+
await w.__aenter__()
10551054

1056-
for w in workers:
1057-
tg.create_task(w.run_until_finished())
1055+
await asyncio.gather(*[w.run_until_finished() for w in workers])
10581056

10591057
for w in workers:
10601058
await w.__aexit__(None, None, None)

0 commit comments

Comments
 (0)