File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
src/superannotate/lib/infrastructure Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 1818
1919
2020class StreamedAnnotations :
21- DELIMITER = b"\\ n;)\\ n"
21+ DELIMITER = "\\ n;)\\ n"
22+ DELIMITER_LEN = len (DELIMITER )
2223
2324 def __init__ (
2425 self ,
@@ -67,12 +68,19 @@ async def fetch(
6768 continue
6869 while buffer :
6970 try :
71+ if buffer .startswith (self .DELIMITER ):
72+ buffer = buffer [self .DELIMITER_LEN :]
7073 json_obj , index = decoder .raw_decode (buffer )
7174 yield json_obj
72- buffer = buffer [index + len (self .DELIMITER ) :].lstrip ()
75+ if len (buffer [index :]) >= self .DELIMITER_LEN :
76+ buffer = buffer [index + self .DELIMITER_LEN :]
77+ else :
78+ buffer = buffer [index :]
79+ break
7380 except json .decoder .JSONDecodeError as e :
7481 logger .debug (
75- f"Failed to parse buffer, buffer_len: { len (buffer )} // buffer_end: ...{ buffer [- 100 :]} , error: { e } "
82+ f"Failed to parse buffer, buffer_len: { len (buffer )} || start buffer:"
83+ f" { buffer [:50 ]} || buffer_end: ...{ buffer [- 50 :]} || error: { e } "
7684 )
7785 break
7886
You can’t perform that action at this time.
0 commit comments