Skip to content

Commit

Permalink
Partial revert of optimisation changes
Browse files Browse the repository at this point in the history
One of the changes in 08ce903 was causing
problems for PJRmi in the Minion set-up. So we revert that part of the change.
  • Loading branch information
iamsrp-deshaw committed Aug 11, 2023
1 parent 5cfda92 commit 9e81647
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 32 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ binpath=
// string in the code. The minor value will be bumped for changes in the wire
// format or major feature additions. The subminor version is typically bumped
// for non-breaking changes, like bugfixes or minor enhancements.
pjrmiVersion=1.12.0
pjrmiVersion=1.12.1
snappyVersion=1.1.0.1
40 changes: 9 additions & 31 deletions python/pjrmi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1307,24 +1307,15 @@ def _recv(self):
# This either happens locally, if we don't have a Receiver thread, or in
# the Receiver thread if we do.

# Keep trying until we get something to give back. Because this is a
# core function the below code is written to avoid excessive operations,
# which is why it's overly verbose.
# Keep trying until we get something to give back
while True:
# Need to read something off the wire. We want 17 bytes in the
# header, which we'll unpack below.
result = None
while True:
if result is None:
to_read = 17
else:
to_read = 17 - len(result)
if to_read <= 0:
break

result = b''
while len(result) < 17:
# Read in the data on the connection; this will block
# until it's read something
chunk = self._transport.recv(to_read)
chunk = self._transport.recv(17 - len(result))

# If the result is empty that's Python telling us the
# we've hit the EOF and the connection is dead
Expand All @@ -1333,29 +1324,16 @@ def _recv(self):
raise EOFError("Connection to Java is closed")

# Add on the bit we read
if result is None:
result = chunk
else:
result += chunk
result += chunk

# See what we got back. Unpack this all in one go so as to avoid the
# overhead of calling _read_foo() multiple times.
(msg_type, thread_id, request_id, payload_size) = struct.unpack('!cqii', result)

# Read the payload
payload = None
while True:
if payload is None:
to_read = payload_size
else:
to_read = payload_size - len(payload)
if to_read <= 0:
break
recvd = self._transport.recv(to_read)
if payload is None:
payload = recvd
else:
payload += recvd
payload = b''
while len(payload) < payload_size:
payload += self._transport.recv(payload_size - len(payload))
assert(len(payload) == payload_size)

# See if it happened to be a callback
Expand Down Expand Up @@ -5526,7 +5504,7 @@ def connect_to_child_jvm(main_class='com.deshaw.pjrmi.UnixFifoProvider',
:param java_executable: The preferred ``java`` executable to use, if any.
:param classpath: A sequence of strings defining the Java classpath.
:param java_args: A sequence of arguments to pass to the Java command.
:param application_args: A sequence of arguments to pass to the PRJmi application.
:param application_args: A sequence of arguments to pass to the PJRmi application.
:param timeout: How long to wait for the child process to connect.
:param stdin: the stdin file, or None to delete the handle.
:param stdout: The stdout file, or None to delete the handle.
Expand Down

0 comments on commit 9e81647

Please sign in to comment.