File tree Expand file tree Collapse file tree 1 file changed +18
-7
lines changed Expand file tree Collapse file tree 1 file changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -1284,16 +1284,27 @@ def get_log(
1284
1284
raise RayStateApiException (r .text )
1285
1285
for bytes in r .iter_content (chunk_size = None ):
1286
1286
bytes = bytearray (bytes )
1287
- # First byte 1 means success.
1288
- if bytes .startswith (b"1" ):
1289
- bytes .pop (0 )
1287
+ # Note that each iteration of the loop doesn't always get
1288
+ # the entire chunk yielded from the server side.
1289
+ # That is, the first byte isn't always 0 or 1.
1290
+ #
1291
+ # 1. If a server chunk starting with b"0" is split into two client chunks,
1292
+ # an error will be raised during iteration of the first client chunk.
1293
+ #
1294
+ # 2. If a client chunk starts with b"1" or any other bytes, it succeeds.
1295
+ #
1296
+ # TODO (kevin85421): We should consider not using the first byte as an
1297
+ # indicator of success or failure. This seems to be an uncommon pattern,
1298
+ # and it doesn't seem important for the client side.
1299
+ if bytes .startswith (b"0" ):
1300
+ error_msg = bytes .decode ("utf-8" )
1301
+ raise RayStateApiException (error_msg )
1302
+ else :
1303
+ if bytes .startswith (b"1" ):
1304
+ bytes .pop (0 )
1290
1305
logs = bytes
1291
1306
if encoding is not None :
1292
1307
logs = bytes .decode (encoding = encoding , errors = errors )
1293
- else :
1294
- assert bytes .startswith (b"0" )
1295
- error_msg = bytes .decode ("utf-8" )
1296
- raise RayStateApiException (error_msg )
1297
1308
yield logs
1298
1309
1299
1310
You can’t perform that action at this time.
0 commit comments