API¶
scell.wrapper¶
Implements the Selector class, a high level
wrapper around ~select.select.
-
class
scell.wrapper.Selector¶ A selector object is a dictionary of file-like objects to
Monitoredobjects.-
info()¶ D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.
-
ready()¶ Yields the registered monitors which are ready (their interests are satisfied).
-
register(fp, mode)¶ Register a given fp (file handle) under a given mode. The mode can either be
r,w, or both. Returns the monitor object.Parameters: - fp – The file-like object.
- mode – Whether read and or write-ready events should be notified.
-
registered¶ D.iteritems() -> an iterator over the (key, value) items of D
-
rwlist()¶ Returns
(rl, wl)whererlandwlare file objects interested in readability and writability, respectively.
-
scoped(*args, **kwds)¶ A context manager that automatically unregisters fps once the block has finished executing.
Parameters: - fps – Iterable of file objects.
- mode – Defaults to ‘rw’, the interests of every file handle.
-
select(timeout=None)¶ Returns an iterable of monitors which are readable or writable subject to timeout.
Parameters: timeout – Maximum number of seconds to wait until at least 1 file object is readable or writable. To block for an indefinite time, use None.
-
unregister¶ x.__delitem__(y) <==> del x[y]
-
scell.core¶
Provides abstractions over lower level APIs and file objects and their interests.
-
class
scell.core.Event(monitored, readable, writable)¶ Represents the readability or writability of a monitored file object.
-
ready¶ Whether the monitored needs are met, i.e. whether it is readable or writable, taking it’s needs into account.
-
-
class
scell.core.Monitored(fp, wants_read, wants_write)¶ Represents the interests of a file handle fp, and whether it wants_read and or wants_write.
-
scell.core.select(rl, wl, timeout=None)¶ Returns the file objects ready for reading/writing from the read-list (rl) and write-list (wl), subject to timeout in seconds.
Parameters: - rl – Objects interested in readability.
- wl – Objects interested in writability.
- timeout – Maximum blocking time in seconds, None for no timeout.