Skip to content

Commit

Permalink
Fixed Pipe FDs closing after first line (isamert#222)
Browse files Browse the repository at this point in the history
* # pipe callbacks now return true

* Addition to workaround for urwid#847

---------

Co-authored-by: exquo <[email protected]>
  • Loading branch information
MareOfNights and exquo authored Feb 28, 2024
1 parent 1ce0315 commit 6d8954f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions scli
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ class Daemon(AsyncContext):
# The `output` (supplied by urwid) is a `bytes` object, even when the `subprocess` is launched with `text=True`.
if self._msg_processing_paused:
self._buffer = output
return
return True
lines = output.split('\n') # Different from splitlines(): adds a final '' element after '\n'
self._buffer = lines.pop()

Expand All @@ -819,7 +819,7 @@ class Daemon(AsyncContext):
except (json.JSONDecodeError, KeyError) as err:
logging.error('Could not parse daemon output: %s', line)
logging.exception(err)
return
return True
logging.debug("Daemon: json_data = \n%s", pprint.pformat(json_data))
error_data = None
for error_key in ('error', 'exception'):
Expand All @@ -830,11 +830,12 @@ class Daemon(AsyncContext):
self._error_data_handler(error_data, envelope)
if error_data is None:
self._envelope_handler(envelope)
return True

def _daemon_stderr_handler(self, output):
line = output.decode().strip()
if not line:
return
return True
logging.info('daemon_log: %s', line)
self.callbacks['daemon_log'](line)
if any(s in line for s in (
Expand All @@ -845,6 +846,7 @@ class Daemon(AsyncContext):
self._run_when_dbus_service_started(
self.callbacks['daemon_started']
)
return True

def _envelope_handler(self, envelope):
envelope['_received_timestamp'] = get_current_timestamp_ms()
Expand Down

0 comments on commit 6d8954f

Please sign in to comment.