Esempio n. 1
0
    def start(self, asynchronous=False, gil=True, **kwargs):
        """
                Enter the main loop to start receiving and dispatching events.

                @@param asynchronous: Should event dispatch be asynchronous
                        (decoupled) from event receiving from the AT-SPI registry?
                @@type asynchronous: boolean
                @@param gil: Add an idle callback which releases the Python GIL for a few
                        milliseconds to allow other threads to run? Necessary if other threads
                        will be used in this process.
                @@type gil: boolean
                """
        if 'async' in kwargs:
            # support previous API
            asynchronous = kwargs['async']
        if not self.has_implementations:
            self._set_default_registry()
        self.started = True

        if gil:

            def releaseGIL():
                try:
                    time.sleep(1e-2)
                except KeyboardInterrupt as e:
                    # store the exception for later
                    releaseGIL.keyboard_exception = e
                    self.stop()
                return True

            # make room for an exception if one occurs during the
            releaseGIL.keyboard_exception = None
            i = GLib.idle_add(releaseGIL)
            Atspi.event_main()
            GLib.source_remove(i)
            if releaseGIL.keyboard_exception is not None:
                # raise an keyboard exception we may have gotten earlier
                raise releaseGIL.keyboard_exception
        else:
            Atspi.event_main()

        self.started = False
Esempio n. 2
0
        def start(self, asynchronous=False, gil=True, **kwargs):
                """
                Enter the main loop to start receiving and dispatching events.

                @@param asynchronous: Should event dispatch be asynchronous
                        (decoupled) from event receiving from the AT-SPI registry?
                @@type asynchronous: boolean
                @@param gil: Add an idle callback which releases the Python GIL for a few
                        milliseconds to allow other threads to run? Necessary if other threads
                        will be used in this process.
                @@type gil: boolean
                """
                if 'async' in kwargs:
                    # support previous API
                    asynchronous = kwargs['async']
                if not self.has_implementations:
                        self._set_default_registry ()
                self.started = True

                if gil:
                        def releaseGIL():
                                try:
                                        time.sleep(1e-2)
                                except KeyboardInterrupt as e:
                                        # store the exception for later
                                        releaseGIL.keyboard_exception = e
                                        self.stop()
                                return True
                        # make room for an exception if one occurs during the 
                        releaseGIL.keyboard_exception = None
                        i = GLib.idle_add(releaseGIL)
                        Atspi.event_main()
                        GLib.source_remove(i)
                        if releaseGIL.keyboard_exception is not None:
                                # raise an keyboard exception we may have gotten earlier
                                raise releaseGIL.keyboard_exception
                else:
                        Atspi.event_main()

                self.started = False
Esempio n. 3
0
                        self._set_default_registry ()
                self.started = True

                if gil:
                        def releaseGIL():
                                try:
                                        time.sleep(1e-2)
                                except KeyboardInterrupt, e:
                                        # store the exception for later
                                        releaseGIL.keyboard_exception = e
                                        self.stop()
                                return True
                        # make room for an exception if one occurs during the 
                        releaseGIL.keyboard_exception = None
                        i = GObject.idle_add(releaseGIL)
                        Atspi.event_main()
                        GObject.source_remove(i)
                        if releaseGIL.keyboard_exception is not None:
                                # raise an keyboard exception we may have gotten earlier
                                raise releaseGIL.keyboard_exception
                else:
                        Atspi.event_main()

                self.started = False

        def stop(self, *args):
                """
                Quits the main loop.
                """
                if not self.has_implementations:
                        self._set_default_registry ()
Esempio n. 4
0
                        self._set_default_registry ()
                self.started = True

                if gil:
                        def releaseGIL():
                                try:
                                        time.sleep(1e-2)
                                except KeyboardInterrupt as e:
                                        # store the exception for later
                                        releaseGIL.keyboard_exception = e
                                        self.stop()
                                return True
                        # make room for an exception if one occurs during the 
                        releaseGIL.keyboard_exception = None
                        i = GLib.idle_add(releaseGIL)
                        Atspi.event_main()
                        GLib.source_remove(i)
                        if releaseGIL.keyboard_exception is not None:
                                # raise an keyboard exception we may have gotten earlier
                                raise releaseGIL.keyboard_exception
                else:
                        Atspi.event_main()

                self.started = False

        def stop(self, *args):
                """
                Quits the main loop.
                """
                if not self.has_implementations:
                        self._set_default_registry ()