How to use the gbulb.unix_events.SelectorEventLoop function in gbulb

To help you get started, we’ve selected a few gbulb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github davidedmundson / telepathy-hangups / gbulb / glib_events.py View on Github external
#        objects and calling .run() recursively)
#     2. when the event loop has not even yet started because it is still
#        trying to acquire the context
#
# It should be wiser not to use any recursion at all. GLibEventLoop will
# actually prevent you from doing that (in accordance with PEP 3156). However
# you should keep in mind that enclosed loops may be started at any time by
# third-party code calling directly GLib's primitives.
#
#
# TODO: documentation about signal GLib allows catching signals from any
# thread. It is dispatched to the first handler whose flag is not yet raised.
#
# about SIGINT -> KeyboardInterrupt will never be raised asynchronously

class BaseGLibEventLoop(unix_events.SelectorEventLoop):
    """GLib base event loop

    This class handles only the operations related to Glib.MainContext objects.

    Glib.MainLoop operations are implemented in the derived classes.
    """

    class DefaultSigINTHandler:
        def __init__(self):
            s = GLib.unix_signal_source_new(signal.SIGINT)
            s.set_callback(self.__class__._callback, self)
            s.attach()

            self._source = s
            self._loop   = None