Commit 18807f2
committed
pybricks/tools/pb_type_async: Don't close if already scheduled.
When forgetting <await> in one or more tasks that use the same resource, the
resource could be scheduled for cancellation but the awaitable is not awaited
and closed, so race=True will trigger the other task to stop and thus try to
cancel it again. But the parent object is already set to MP_OBJ_SENTINEL at
this point, so evaluating close(parent) segfaults.
The block code generator should be fixed to include await, but we also
shouldn't segfault in case the user forgets await in their own user code.
See pybricks/support#26211 parent 9ffaf56 commit 18807f2
3 files changed
Lines changed: 8 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
18 | 21 | | |
19 | 22 | | |
20 | 23 | | |
21 | 24 | | |
| 25 | + | |
22 | 26 | | |
23 | 27 | | |
24 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
40 | 42 | | |
41 | 43 | | |
42 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
0 commit comments