eww.quitterproxy

QuitterProxy is a threading.local-based proxy used to override the normal quit behavior on demand. It is very similar to IOProxy, but rather than proxying files, it proxies Quitter objects. We need to do this so calling exit() or quit() in the REPL won’t kill the console connection.

This is because calling quit()/exit() will raise the SystemExit exception, and close stdin. We can catch the SystemExit exception, but if stdin is closed, it kills our socket.

Normally that’s exactly the behavior you want, but because we embed a REPL in the Eww console, exiting the REPL can cause the entire session to exit, not just the REPL.

If you want to make modifications to the quit or exit builtins, you can use the public register/unregister APIs on QuitterProxy for it. It works the same way as on IOProxy objects.

class eww.quitterproxy.QuitterProxy(original_quit)[source]

Bases: object

QuitterProxy provides a proxy object meant to replace __builtin__.[quit, exit]. You can register your own quit customization by calling register()/unregister().

__call__(code=None)[source]

Calls the registered quit method.

Parameters:code (str) – A quit message.
__init__(original_quit)[source]

Creates the thread local and registers the original quit.

Parameters:original_quit (Quitter) – The original quit method. We keep a reference to it since we’re replacing it.
__repr__()[source]

We just call self here, that way people can use e.g. ‘exit’ instead of ‘exit()’.

__weakref__

list of weak references to the object (if defined)

register(quit_method)[source]

Used to register a quit method in a particular thread.

Parameters:quit_method (callable) – A callable that will be called instead of original_quit.
Returns:None
unregister()[source]

Used to unregister a quit method in a particular thread.

Returns:None
eww.quitterproxy.safe_quit(code=None)[source]

This version of the builtin quit method raises a SystemExit, but does not close stdin.

Parameters:code (str) – A quit message.