Skip to content

Commit 4841186

Browse files
committed
CABI: tidy stream code a bit (no change)
1 parent 820c64e commit 4841186

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

design/mvp/CanonicalABI.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3792,6 +3792,7 @@ the other end closed, or this end cancelled the copy via
37923792
```python
37933793
def copy_event(why, revoke_buffer):
37943794
revoke_buffer()
3795+
assert(e.copying)
37953796
e.copying = False
37963797
return (event_code, i, pack_copy_result(task, e, buffer, why))
37973798

@@ -3810,13 +3811,13 @@ synchronously returns how much was copied and how the operation ended to the
38103811
caller. Otherwise, the built-in blocks:
38113812
```python
38123813
else:
3814+
e.copying = True
38133815
if opts.sync:
38143816
await task.wait_on(e.wait_for_pending_event(), sync = True)
38153817
code,index,payload = e.get_event()
38163818
assert(code == event_code and index == i)
38173819
return [payload]
38183820
else:
3819-
e.copying = True
38203821
return [BLOCKED]
38213822
```
38223823
In the synchronous case, the caller synchronously waits for progress

design/mvp/canonical-abi/definitions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2197,6 +2197,7 @@ async def copy(EndT, BufferT, event_code, stream_or_future_t, opts, task, i, ptr
21972197

21982198
def copy_event(why, revoke_buffer):
21992199
revoke_buffer()
2200+
assert(e.copying)
22002201
e.copying = False
22012202
return (event_code, i, pack_copy_result(task, e, buffer, why))
22022203

@@ -2209,13 +2210,13 @@ def on_copy_done(why):
22092210
if e.copy(task.inst, buffer, on_partial_copy, on_copy_done) == 'done':
22102211
return [pack_copy_result(task, e, buffer, 'completed')]
22112212
else:
2213+
e.copying = True
22122214
if opts.sync:
22132215
await task.wait_on(e.wait_for_pending_event(), sync = True)
22142216
code,index,payload = e.get_event()
22152217
assert(code == event_code and index == i)
22162218
return [payload]
22172219
else:
2218-
e.copying = True
22192220
return [BLOCKED]
22202221

22212222
BLOCKED = 0xffff_ffff

0 commit comments

Comments
 (0)