From 9e4b513ad7135157400093eb5d5f2647f91dfa91 Mon Sep 17 00:00:00 2001 From: termer Date: Sat, 1 Apr 2023 17:07:11 -0400 Subject: [PATCH] attempt #3 ??? 10s blocks on concurrent calls, eventually complete is called before write --- src/httpx.nim | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/httpx.nim b/src/httpx.nim index 7cceeda..c8eee29 100644 --- a/src/httpx.nim +++ b/src/httpx.nim @@ -490,10 +490,10 @@ proc processEvents(selector: Selector[Data], echo "WHILE TRUE LOOP TOP" # If the request body stream queue is full, wait until it stops being full - # when httpxUseStreams: - # if unlikely(data.bodyStream.len >= httpxMaxStreamQueueSize): - # echo "BREAK" - # break + when httpxUseStreams: + if unlikely(data.bodyStream.len >= httpxMaxStreamQueueSize): + echo "BREAK" + break echo "Waiting on RECV..." let ret = recv(fd.SocketHandle, addr buf[0], httpxClientBufSize, 0.cint) @@ -606,9 +606,7 @@ proc processEvents(selector: Selector[Data], for i in 0 ..< ret: chunk[i] = buf[i] - # TODO Figure out better workaround - if likely(not data.bodyStream.finished): - asyncCheck data.bodyStream.write(chunk) + asyncCheck data.bodyStream.write(chunk) data.bodyBytesRead += ret.BiggestUInt echo "WROTE, NOW SIZE: " & $data.bodyBytesRead