Skip to content

Commit

Permalink
fixes to have test_record_padding test pass
Browse files Browse the repository at this point in the history
  • Loading branch information
johubertj committed Feb 13, 2025
1 parent 3e48f83 commit d820938
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tests/integrationv2/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def _communicate(self, input_data=None, send_marker_list=None, close_marker=None
self._check_timeout(endtime, orig_timeout, stdout, stderr)

# (Key, events) tuple represents a single I/O operation
for key, events in ready:
for key, num_events in ready:
# STDIN is only registered to receive events after the send_marker is found.
if key.fileobj is self.proc.stdin:
print(f'{self.name}: stdin available')
Expand All @@ -190,14 +190,17 @@ def _communicate(self, input_data=None, send_marker_list=None, close_marker=None
send_marker = send_marker_list.pop(0)
print(f'{self.name}: next send_marker is {send_marker}')
elif key.fileobj in (self.proc.stdout, self.proc.stderr):
print(f'{self.name}: stdout available')
fd_name = self.get_fd_name(self.proc, key.fileobj)
print(f'{self.name}: {fd_name} available')

# 32 KB (32 × 1024 = 32,768 bytes), read 32KB from the file descriptor
data = os.read(key.fd, 32768)
if not data:
selector.unregister(key.fileobj)
print(f"{self.name}: Unregistering: {fd_name} No Data")

data_str = str(data)
print(f"raw data read from {self.name}: {data_str}")

# Prepends n - 1 bytes of previously-seen stdout to the chunk we'll be searching
# through, where n is the size of the send_marker we're currently looking for.
Expand Down Expand Up @@ -255,8 +258,7 @@ def _communicate(self, input_data=None, send_marker_list=None, close_marker=None
selector.unregister(self.proc.stderr)
self.proc.kill()

# We check for the close marker in every iteration to ensure that we properly close stdin as soon as the expected
# marker appears in the output. This prevents unnecessary waiting and avoids potential errors.
# During every iteration check to see if we have found a close marker to see if we should close stdin
if self.proc.stdin and input_data_sent and not input_data:
print(f'{self.name}: finished sending')
if close_marker:
Expand Down

0 comments on commit d820938

Please sign in to comment.