Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update recvuntil #29

Merged
merged 2 commits into from
Mar 25, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: not sleep when found
  • Loading branch information
rqdaA committed Mar 24, 2024
commit e541ad9f4dadb558a870efe50a45d12ddabb4bd3
9 changes: 6 additions & 3 deletions ptrlib/connection/tube.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,20 +157,23 @@ def recvuntil(self,

found = False
token = None
while not found:
while True:
try:
data += self.recv(size, timeout=-1)
except TimeoutError as err:
raise TimeoutError("`recvuntil` timeout", data + err.args[1])
if sleep_time > 0:
time.sleep(sleep_time)

for t in delim:
if t in data:
found = True
token = t
break

if found:
break
if sleep_time:
time.sleep(sleep_time)

found_pos = data.find(token)
result_len = found_pos if drop else found_pos + len(token)
consumed_len = found_pos if lookahead else found_pos + len(token)
Expand Down