Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

Commit

Permalink
Add support for driving BufferedProtocol instances using `sock_recv…
Browse files Browse the repository at this point in the history
…_into`

Support for this feature is emulated for the `Pipe{Read,Write}Transport`
however, since `glib.IOChannel` does not appear to expose anything similar
to the `recvinto` syscall in its APIs. The emulation at least makes it possible
to use `BufferedProtocol` instances without causing crashes due to API
differences versus the classic `Protocol` interface at least.
  • Loading branch information
ntninja committed Nov 4, 2022
1 parent 5aee5a5 commit 1ffbc38
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/gbulb/transports.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ def _submit_read_data(self, data):
def _loop_reading(self, fut=None):
if self._paused:
return
data = None

try:
data = None
if fut is not None:
assert self._read_fut is fut or (
self._read_fut is None and self._closing
Expand All @@ -171,7 +171,7 @@ def _loop_reading(self, fut=None):
data = None
return

if data == b"" or data == 0:
if data == b"":
# No need to reschedule on end-of-file
return

Expand All @@ -193,9 +193,6 @@ def _loop_reading(self, fut=None):
self._cancelable.add(self._read_fut)
else:
self._read_fut.add_done_callback(self._loop_reading)
finally:
if data is not None:
self._submit_read_data(data)


class WriteTransport(BaseTransport, transports._FlowControlMixin):
Expand Down

0 comments on commit 1ffbc38

Please sign in to comment.