-
Notifications
You must be signed in to change notification settings - Fork 320
Feature: Add internal logging for behavioral debug #708
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
Conversation
* Use standard python logging * Use nested loggers for possibility to set atomic logging * Add `__repr__` to the part of critical types * In screen event loop with `selectors` usage: use IO objects instead of descriptors if possible: get human-friendly output in logs * `MainLoop` methods`watch_pipe` / `remove_watch_pipe` are not available under Windows
Pull Request Test Coverage Report for Build 7220483902
💛 - Coveralls |
* These are only for type checking.
@@ -371,7 +382,7 @@ def get_cols_rows(self) -> tuple[int, int]: | |||
y, x = super().get_cols_rows() | |||
with contextlib.suppress(OSError): # Term size could not be determined | |||
if hasattr(self._term_output_file, "fileno"): | |||
buf = fcntl.ioctl(self._term_output_file.fileno(), termios.TIOCGWINSZ, " " * 4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is buggy code: ioctl expect Buffer protocol, which includes bytes
, but not str
|
||
class Screen(BaseScreen, RealTerminal): | ||
def __init__(self, input: FileLikeObj, output: FileLikeObj): # noqa: A002 | ||
def __init__(self, input: io.IOBase, output: io.IOBase): # noqa: A002 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use full type
@@ -171,7 +173,7 @@ def wrapper() -> tuple[list[str], typing.Any] | None: | |||
return self.parse_input(event_loop, callback, self.get_available_raw_input()) | |||
|
|||
fds = self.get_input_descriptors() | |||
handles = [event_loop.watch_file(fd, wrapper) for fd in fds] | |||
handles = [event_loop.watch_file(fd if isinstance(fd, int) else fd.fileno(), wrapper) for fd in fds] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not break EventLoop API
try: | ||
watch_handle, pipe_rd = self._watch_pipes.pop(write_fd) | ||
except KeyError: | ||
return False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is mainly used to trigger a screen update from a signal (like the terminal resize) or from another process/thread. On windows we need something like this, maybe a socket pair connected over loopback?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/urwid/urwid/blob/master/urwid/_win32_raw_display.py#L247 ->
https://github.com/urwid/urwid/blob/master/urwid/_win32_raw_display.py#L165C77-L165C94 ->
https://github.com/urwid/urwid/blob/master/urwid/_raw_display_base.py#L99
And socket
instance is used for sending b"R"
to trigger update.
Unfortunately it's not enough, so issue #700 created and in process of debugging, when I have physical access to the Windows machine.
Use standard python logging
Use nested loggers for possibility to set atomic logging
Add
__repr__
to the part of critical typesIn screen event loop with
selectors
usage: use IO objects instead of descriptors if possible: get human-friendly output in logsMainLoop
methodswatch_pipe
/remove_watch_pipe
are not available under WindowsChecklist
master
orpython-dual-support
branchtox
successfully in local environment