curses, multiplexing, select / poll, and resizing
frobenius
frob1 at archerlabs.net
Tue Jul 16 00:04:02 EDT 2002
preface: i'm new to python, semi-new to curses, but an otherwise
experienced programmer.
i'm writing a telnet client using curses to separate input and output
into different windows. to multiplex the I/O from the user and the
host i'm using poll(). when i resize the terminal window (i'm using
win32 PuTTY to connect to FreeBSD, running Python 2.2) i generate an
exception which kills poll():
Select Error: 4, Interrupted system call
without a useful traceback (AFAICT).
i searched online for help, found the source to cplay: a python curses
front-end to various audio apps. in there the programmers has the
code
signal.signal(signal.SIGWINCH, self.handler_resize)
followed by the code
def handler_resize(self, sig, frame):
## curses trickery
curses.endwin()
self.w.refresh()
[more update stuff.....]
i've tried to adapt this trick to work with my program, but even
though i register a signal handler for the resize signal, the poll()
still gets a select.error exception triggered, AFTER the signal
handler has returned.
- how to i capture and ignore this w/out accidentally capturing a real
poll() error?
- as far as documentation goes, there's some serious magic with this
endwin / refresh handler trick. (i finally found out what it does by
consulting the ncurses manpages.) i feel like terminal window resize
issues are common enough that people should have documentation on this
somewhere, e.g. in the python curses tutorial.
- where is the curses module source? i found the submodules
(curses.ascii, etc.) in
/usr/local/lib/python-2.2/curses/
on my machine but can't seem to be able to find the base package
source.
- other gotchas?
thanks in advance, Frob
PS i'll probably end up contributing my python-curses readline
library, which makes nice single-line entry pads.
More information about the Python-list
mailing list