Python: module boodle.listen

boodle.listen | index boodle/listen.py

`listen: A module containing ways for Boodler to listen to external
events.
SocketListener -- listen for events on an Internet or Unix domain socket
StdinListener -- listen for events on stdin
(Logically these are subclasses of a base Listener class, but I didn't
implement it that way.)`

Modules
`` |  |
boodle errno | fcntl os | select socket | sys

Classes
`` |  | SocketListener StdinListener
class SocketListener
`` | `SocketListener: Listen for events on an Internet or Unix domain socket. This opens a socket; external processes can connect and send Boodler events to it. You can open either Internet sockets (with a numeric port number), or Unix domain sockets. (Unix sockets exist as a "file" on disk; only processes on the same machine can connect to a Unix socket.) SocketListener(handler, listenport=31863) -- constructor The socket is opened as soon as the SocketListener is constructed. If listenport is an integer, this will be an Internet socket. If listenport is a string, it will be a Unix domain socket. Events will be sent to the handler function. Public methods: poll() -- read as many events as are available close() -- close the socket`
| Methods defined here: __init__(self, handler, listenport=None) close(self) poll(self) Data and other attributes defined here: unlinkport = None
class StdinListener
`` | `StdinListener: Listen for events arriving on standard input. This is intended for when Boodler is running as a subordinate process in some other program. The hosting program can write event data in to Boodler. StdinListener(handler) -- constructor Events will be sent to the handler function. Public methods: poll() -- read as many events as are available close() -- close the socket`
| Methods defined here: __init__(self, handler) close(self) poll(self)

Functions
`` |  | handle_by_lines(handler, dat) `handle_by_lines(handler, dat) -> str Take an input buffer, parse as many events out of it as possible, handle them, and return the remainder. For each valid event, the handler argument will be called with the event tuple for an argument. An event is a newline-terminated string (which is not just whitespace). So the returned value will be the remainder after the last newline. The event line is split on whitespace, producing a tuple of strings.`