diff options
| author | Damien George <damien@micropython.org> | 2022-04-21 13:17:33 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2022-04-21 14:25:17 +1000 |
| commit | f7454f850feaeef7f567e434205ad648192ba01b (patch) | |
| tree | a504047390580a53b0afa9170b484018806f1c49 /extmod/uasyncio/task.py | |
| parent | 8631753ff450850fabc7cb925b829030f0e51f44 (diff) | |
extmod/uasyncio: Make Python Task match C version with use of asserts.
This helps to catch bugs when a Task is put on more than one pairing heap.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'extmod/uasyncio/task.py')
| -rw-r--r-- | extmod/uasyncio/task.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/extmod/uasyncio/task.py b/extmod/uasyncio/task.py index d77516490..94768b95a 100644 --- a/extmod/uasyncio/task.py +++ b/extmod/uasyncio/task.py @@ -100,10 +100,10 @@ class TaskQueue: return self.heap def push_sorted(self, v, key): + assert v.ph_child is None + assert v.ph_next is None v.data = None v.ph_key = key - v.ph_child = None - v.ph_next = None self.heap = ph_meld(v, self.heap) def push_head(self, v): @@ -111,7 +111,9 @@ class TaskQueue: def pop_head(self): v = self.heap - self.heap = ph_pairing(self.heap.ph_child) + assert v.ph_next is None + self.heap = ph_pairing(v.ph_child) + v.ph_child = None return v def remove(self, v): |
