Commit 5af635c
Fix resource cleanup and achieve 100% test coverage
This commit fixes several resource cleanup issues and adds comprehensive
tests to achieve 100% code coverage.
## Fixes
### RedisStore Cleanup (docket.py)
- Add proper cleanup of result_storage in Docket.__aexit__()
- RedisStore maintains its own connection pool that wasn't being closed
- Fixes ResourceWarning about unclosed connections
### Test Mock Cleanup (test_execution_progress.py)
- Fix incomplete Redis async context manager mocks
- Add __aexit__ configuration to prevent connection cleanup warnings
- Applied to test_execution_sync_with_missing_state_field and
test_execution_sync_with_string_state_value
### Exception Pickling (test_results.py)
- Fix CustomError to properly pickle/unpickle
- Pass both args to super().__init__() to preserve exception state
### Timeout Handling (execution.py)
- Fix get_result() timeout to work even when no events arrive
- Wrap subscribe loop with asyncio.wait_for()
- Add early check for already-expired timeouts
## New Tests
Added 4 tests to test_results.py for 100% coverage:
- test_get_result_with_expired_timeout
- test_get_result_failed_task_without_result_key
- test_get_result_with_malformed_result_data
- test_get_result_failed_task_with_missing_exception_data
## Results
- All 395 tests passing
- 100% code coverage achieved
- No resource warnings
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent 43dc964 commit 5af635c
File tree
6 files changed
+161
-94
lines changed- src/docket
- tests
6 files changed
+161
-94
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
174 | 175 | | |
175 | 176 | | |
176 | 177 | | |
| 178 | + | |
| 179 | + | |
177 | 180 | | |
178 | 181 | | |
179 | 182 | | |
| |||
230 | 233 | | |
231 | 234 | | |
232 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
233 | 240 | | |
234 | 241 | | |
235 | 242 | | |
| |||
238 | 245 | | |
239 | 246 | | |
240 | 247 | | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
241 | 251 | | |
242 | 252 | | |
243 | 253 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | 66 | | |
90 | 67 | | |
91 | 68 | | |
| |||
261 | 238 | | |
262 | 239 | | |
263 | 240 | | |
264 | | - | |
| 241 | + | |
265 | 242 | | |
266 | 243 | | |
267 | 244 | | |
| |||
350 | 327 | | |
351 | 328 | | |
352 | 329 | | |
353 | | - | |
| 330 | + | |
354 | 331 | | |
355 | 332 | | |
356 | 333 | | |
| |||
672 | 649 | | |
673 | 650 | | |
674 | 651 | | |
675 | | - | |
| 652 | + | |
676 | 653 | | |
677 | 654 | | |
678 | 655 | | |
| |||
682 | 659 | | |
683 | 660 | | |
684 | 661 | | |
685 | | - | |
| 662 | + | |
686 | 663 | | |
687 | | - | |
| 664 | + | |
688 | 665 | | |
689 | 666 | | |
690 | 667 | | |
| |||
710 | 687 | | |
711 | 688 | | |
712 | 689 | | |
713 | | - | |
| 690 | + | |
714 | 691 | | |
715 | 692 | | |
716 | 693 | | |
717 | 694 | | |
718 | 695 | | |
719 | 696 | | |
720 | | - | |
| 697 | + | |
721 | 698 | | |
722 | | - | |
| 699 | + | |
723 | 700 | | |
724 | 701 | | |
725 | 702 | | |
| |||
746 | 723 | | |
747 | 724 | | |
748 | 725 | | |
| 726 | + | |
749 | 727 | | |
750 | 728 | | |
751 | 729 | | |
752 | 730 | | |
753 | | - | |
754 | | - | |
755 | | - | |
756 | | - | |
757 | | - | |
758 | | - | |
759 | | - | |
760 | | - | |
761 | | - | |
762 | | - | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
763 | 736 | | |
764 | 737 | | |
765 | 738 | | |
766 | 739 | | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
767 | 761 | | |
768 | 762 | | |
769 | | - | |
| 763 | + | |
770 | 764 | | |
771 | | - | |
| 765 | + | |
772 | 766 | | |
773 | 767 | | |
774 | 768 | | |
| |||
779 | 773 | | |
780 | 774 | | |
781 | 775 | | |
782 | | - | |
783 | | - | |
| 776 | + | |
| 777 | + | |
784 | 778 | | |
785 | 779 | | |
786 | 780 | | |
| |||
818 | 812 | | |
819 | 813 | | |
820 | 814 | | |
821 | | - | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
822 | 818 | | |
823 | 819 | | |
824 | 820 | | |
825 | 821 | | |
826 | 822 | | |
827 | 823 | | |
828 | 824 | | |
829 | | - | |
| 825 | + | |
830 | 826 | | |
831 | 827 | | |
832 | 828 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
676 | 676 | | |
677 | 677 | | |
678 | 678 | | |
679 | | - | |
680 | | - | |
681 | | - | |
682 | | - | |
683 | | - | |
684 | | - | |
| 679 | + | |
685 | 680 | | |
686 | 681 | | |
687 | 682 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
| 199 | + | |
199 | 200 | | |
200 | 201 | | |
201 | 202 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
716 | 716 | | |
717 | 717 | | |
718 | 718 | | |
719 | | - | |
720 | | - | |
721 | | - | |
722 | | - | |
723 | | - | |
724 | | - | |
725 | | - | |
726 | | - | |
727 | | - | |
728 | | - | |
729 | | - | |
730 | | - | |
731 | | - | |
732 | | - | |
733 | | - | |
734 | | - | |
735 | | - | |
736 | 719 | | |
737 | 720 | | |
738 | 721 | | |
| |||
755 | 738 | | |
756 | 739 | | |
757 | 740 | | |
| 741 | + | |
758 | 742 | | |
759 | 743 | | |
760 | 744 | | |
| |||
786 | 770 | | |
787 | 771 | | |
788 | 772 | | |
| 773 | + | |
789 | 774 | | |
790 | 775 | | |
791 | 776 | | |
| |||
818 | 803 | | |
819 | 804 | | |
820 | 805 | | |
821 | | - | |
| 806 | + | |
822 | 807 | | |
823 | 808 | | |
824 | 809 | | |
| |||
839 | 824 | | |
840 | 825 | | |
841 | 826 | | |
842 | | - | |
| 827 | + | |
843 | 828 | | |
844 | 829 | | |
845 | 830 | | |
| |||
0 commit comments