@@ -52,9 +52,9 @@ being specified here.
52
52
* [ ` canon {stream,future}.{read,write} ` ] ( #-canon-streamfuturereadwrite ) 🔀
53
53
* [ ` canon {stream,future}.cancel-{read,write} ` ] ( #-canon-streamfuturecancel-readwrite ) 🔀
54
54
* [ ` canon {stream,future}.close-{readable,writable} ` ] ( #-canon-streamfutureclose-readablewritable ) 🔀
55
- * [ ` canon error-context.new ` ] ( #-canon-error-contextnew ) 🔀
56
- * [ ` canon error-context.debug-message ` ] ( #-canon-error-contextdebug-message ) 🔀
57
- * [ ` canon error-context.drop ` ] ( #-canon-error-contextdrop ) 🔀
55
+ * [ ` canon error-context.new ` ] ( #-canon-error-contextnew ) 📝
56
+ * [ ` canon error-context.debug-message ` ] ( #-canon-error-contextdebug-message ) 📝
57
+ * [ ` canon error-context.drop ` ] ( #-canon-error-contextdrop ) 📝
58
58
* [ ` canon thread.spawn_ref ` ] ( #-canon-threadspawn_ref ) 🧵
59
59
* [ ` canon thread.spawn_indirect ` ] ( #-canon-threadspawn_indirect ) 🧵
60
60
* [ ` canon thread.available_parallelism ` ] ( #-canon-threadavailable_parallelism ) 🧵
@@ -1062,9 +1062,8 @@ class ReadableStream:
1062
1062
t: ValType
1063
1063
read: Callable[[WritableBuffer, OnPartialCopy, OnCopyDone], Literal[' done' ,' blocked' ]]
1064
1064
cancel: Callable[[], None ]
1065
- close: Callable[[Optional[ErrorContext] ]]
1065
+ close: Callable[[]]
1066
1066
closed: Callable[[], bool ]
1067
- closed_with: Callable[[], Optional[ErrorContext]]
1068
1067
```
1069
1068
The key operation is ` read ` which works as follows:
1070
1069
* ` read ` is non-blocking, returning ` 'blocked' ` if it would have blocked.
@@ -1100,7 +1099,6 @@ class in chunks, starting with the fields and initialization:
1100
1099
class ReadableStreamGuestImpl (ReadableStream ):
1101
1100
impl: ComponentInstance
1102
1101
closed_: bool
1103
- maybe_errctx: Optional[ErrorContext]
1104
1102
pending_buffer: Optional[Buffer]
1105
1103
pending_on_partial_copy: Optional[OnPartialCopy]
1106
1104
pending_on_copy_done: Optional[OnCopyDone]
@@ -1109,7 +1107,6 @@ class ReadableStreamGuestImpl(ReadableStream):
1109
1107
self .t = t
1110
1108
self .impl = inst
1111
1109
self .closed_ = False
1112
- self .maybe_errctx = None
1113
1110
self .reset_pending()
1114
1111
1115
1112
def reset_pending (self ):
@@ -1135,19 +1132,14 @@ been returned:
1135
1132
def cancel (self ):
1136
1133
self .reset_and_notify_pending()
1137
1134
1138
- def close (self , maybe_errctx ):
1135
+ def close (self ):
1139
1136
if not self .closed_:
1140
1137
self .closed_ = True
1141
- self .maybe_errctx = maybe_errctx
1142
1138
if self .pending_buffer:
1143
1139
self .reset_and_notify_pending()
1144
1140
1145
1141
def closed (self ):
1146
1142
return self .closed_
1147
-
1148
- def closed_with (self ):
1149
- assert (self .closed_)
1150
- return self .maybe_errctx
1151
1143
```
1152
1144
While the abstract ` ReadableStream ` interface * allows* ` cancel ` to return
1153
1145
without having returned ownership of the buffer (which, in general, is
@@ -1212,9 +1204,9 @@ class StreamEnd(Waitable):
1212
1204
self .stream = stream
1213
1205
self .copying = False
1214
1206
1215
- def drop (self , maybe_errctx ):
1207
+ def drop (self ):
1216
1208
trap_if(self .copying)
1217
- self .stream.close(maybe_errctx )
1209
+ self .stream.close()
1218
1210
Waitable.drop(self )
1219
1211
1220
1212
class ReadableStreamEnd (StreamEnd ):
@@ -1251,11 +1243,11 @@ class FutureEnd(StreamEnd):
1251
1243
assert (buffer.remain() == 1 )
1252
1244
def on_copy_done_wrapper ():
1253
1245
if buffer.remain() == 0 :
1254
- self .stream.close(maybe_errctx = None )
1246
+ self .stream.close()
1255
1247
on_copy_done()
1256
1248
ret = copy_op(buffer, on_partial_copy = None , on_copy_done = on_copy_done_wrapper)
1257
1249
if ret == ' done' and buffer.remain() == 0 :
1258
- self .stream.close(maybe_errctx = None )
1250
+ self .stream.close()
1259
1251
return ret
1260
1252
1261
1253
class ReadableFutureEnd (FutureEnd ):
@@ -1266,9 +1258,8 @@ class WritableFutureEnd(FutureEnd):
1266
1258
paired: bool = False
1267
1259
def copy (self , src , on_partial_copy , on_copy_done ):
1268
1260
return self .close_after_copy(self .stream.write, src, on_copy_done)
1269
- def drop (self , maybe_errctx ):
1270
- trap_if(not self .stream.closed() and not maybe_errctx)
1271
- FutureEnd.drop(self , maybe_errctx)
1261
+ def drop (self ):
1262
+ FutureEnd.drop(self )
1272
1263
```
1273
1264
The ` future.{read,write} ` built-ins fix the buffer length to ` 1 ` , ensuring the
1274
1265
` assert(buffer.remain() == 1) ` holds. Because of this, there are no partial
@@ -3607,14 +3598,7 @@ def pack_copy_result(task, buffer, e):
3607
3598
assert (not (buffer.progress & CLOSED ))
3608
3599
return buffer.progress
3609
3600
else :
3610
- if (maybe_errctx := e.stream.closed_with()):
3611
- errctxi = task.inst.error_contexts.add(maybe_errctx)
3612
- assert (errctxi != 0 )
3613
- else :
3614
- errctxi = 0
3615
- assert (errctxi <= Table.MAX_LENGTH < BLOCKED )
3616
- assert (not (errctxi & CLOSED ))
3617
- return errctxi | CLOSED
3601
+ return CLOSED
3618
3602
```
3619
3603
The order of tests here indicates that, if some progress was made and then the
3620
3604
stream was closed, only the progress is reported and the ` CLOSED ` status is
@@ -3705,41 +3689,29 @@ the given index from the current component instance's `waitable` table,
3705
3689
performing the guards and bookkeeping defined by
3706
3690
` {Readable,Writable}{Stream,Future}End.drop() ` above.
3707
3691
``` python
3708
- async def canon_stream_close_readable (t , task , i , errctxi ):
3709
- return await close(ReadableStreamEnd, t, task, i, errctxi )
3692
+ async def canon_stream_close_readable (t , task , i ):
3693
+ return await close(ReadableStreamEnd, t, task, i)
3710
3694
3711
- async def canon_stream_close_writable (t , task , hi , errctxi ):
3712
- return await close(WritableStreamEnd, t, task, hi, errctxi )
3695
+ async def canon_stream_close_writable (t , task , hi ):
3696
+ return await close(WritableStreamEnd, t, task, hi)
3713
3697
3714
- async def canon_future_close_readable (t , task , i , errctxi ):
3715
- return await close(ReadableFutureEnd, t, task, i, errctxi )
3698
+ async def canon_future_close_readable (t , task , i ):
3699
+ return await close(ReadableFutureEnd, t, task, i)
3716
3700
3717
- async def canon_future_close_writable (t , task , hi , errctxi ):
3718
- return await close(WritableFutureEnd, t, task, hi, errctxi )
3701
+ async def canon_future_close_writable (t , task , hi ):
3702
+ return await close(WritableFutureEnd, t, task, hi)
3719
3703
3720
- async def close (EndT , t , task , hi , errctxi ):
3704
+ async def close (EndT , t , task , hi ):
3721
3705
trap_if(not task.inst.may_leave)
3722
3706
e = task.inst.waitables.remove(hi)
3723
- if errctxi == 0 :
3724
- maybe_errctx = None
3725
- else :
3726
- maybe_errctx = task.inst.error_contexts.get(errctxi)
3727
3707
trap_if(not isinstance (e, EndT))
3728
3708
trap_if(e.stream.t != t)
3729
- e.drop(maybe_errctx )
3709
+ e.drop()
3730
3710
return []
3731
3711
```
3732
- Passing a non-zero ` errctxi ` index indicates that this stream end is being
3733
- closed due to an error, with the given ` error-context ` providing information
3734
- that can be printed to aid in debugging. While, as explained above, the
3735
- * contents* of the ` error-context ` value are non-deterministic (and may, e.g.,
3736
- be empty), the presence or absence of an ` error-context ` value is semantically
3737
- meaningful for distinguishing between success or failure. Concretely, the
3738
- packed ` i32 ` returned by ` {stream,future}.{read,write} ` operations indicates
3739
- success or failure by whether the ` error-context ` index is ` 0 ` or not.
3740
3712
3741
3713
3742
- ### 🔀 ` canon error-context.new `
3714
+ ### 📝 ` canon error-context.new `
3743
3715
3744
3716
For a canonical definition:
3745
3717
``` wat
@@ -3780,7 +3752,7 @@ are not checked. (Note that `host_defined_transformation` is not defined by the
3780
3752
Canonical ABI and stands for an arbitrary host-defined function.)
3781
3753
3782
3754
3783
- ### 🔀 ` canon error-context.debug-message `
3755
+ ### 📝 ` canon error-context.debug-message `
3784
3756
3785
3757
For a canonical definition:
3786
3758
``` wat
@@ -3808,7 +3780,7 @@ async def canon_error_context_debug_message(opts, task, i, ptr):
3808
3780
Note that ` ptr ` points to an 8-byte region of memory into which will be stored
3809
3781
the pointer and length of the debug string (allocated via ` opts.realloc ` ).
3810
3782
3811
- ### 🔀 ` canon error-context.drop `
3783
+ ### 📝 ` canon error-context.drop `
3812
3784
3813
3785
For a canonical definition:
3814
3786
``` wat
0 commit comments