Commit 230bb64
refactor: Adopt asyncio.TaskGroup for structured concurrency (#643)
## Summary
- Replace manual task management (`create_task` + `cancel` + `gather`)
with `asyncio.TaskGroup` in `RequestQueueClientAsync.batch_add_requests`
for better error propagation and automatic cleanup
- Update docs example (`02_tasks_async.py`) to use `asyncio.TaskGroup`
instead of `asyncio.gather`
- `StreamedLogAsync` and `StatusMessageWatcherAsync` left unchanged —
`TaskGroup` doesn't fit their `start()`/`stop()` lifecycle pattern and
adds no benefit for single-task cases
## Issue
- Closes #598
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent a293601 commit 230bb64
File tree
2 files changed
+24
-22
lines changed- docs/03_examples/code
- src/apify_client/_resource_clients
2 files changed
+24
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | | - | |
35 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
798 | 798 | | |
799 | 799 | | |
800 | 800 | | |
801 | | - | |
802 | 801 | | |
803 | 802 | | |
804 | 803 | | |
| |||
815 | 814 | | |
816 | 815 | | |
817 | 816 | | |
818 | | - | |
819 | | - | |
820 | | - | |
821 | | - | |
822 | | - | |
823 | | - | |
824 | | - | |
825 | | - | |
826 | | - | |
827 | | - | |
828 | | - | |
829 | | - | |
830 | | - | |
831 | | - | |
832 | | - | |
833 | | - | |
834 | | - | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
835 | 835 | | |
836 | 836 | | |
837 | 837 | | |
838 | 838 | | |
839 | 839 | | |
840 | | - | |
| 840 | + | |
| 841 | + | |
841 | 842 | | |
842 | 843 | | |
843 | 844 | | |
| |||
0 commit comments