예제 #1
0
    def __init__(self, url, readycallback, userdata):
        GLib.Source.__init__(self)

        self._queue = Queue()
        self._readycallback = readycallback
        self._userdata = userdata
        self._resolver = GetURLTitleThread(url, self._queue)
        self._resolver.start()
예제 #2
0
    def __init__(self, url, readycallback, userdata):
        GLib.Source.__init__(self)

        self._queue = Queue()
        self._readycallback = readycallback
        self._userdata = userdata
        self._resolver = GetURLTitleThread(url, self._queue)
        self._resolver.start()
예제 #3
0
class GetURLTitleThreadSource(GLib.Source):
    """Runs thread and waits until the thread does not return the url's title
    """

    #pylint: disable=W0613
    def __new__(cls, *args):
        return GLib.Source.__new__(cls)

    def __init__(self, url, readycallback, userdata):
        GLib.Source.__init__(self)

        self._queue = Queue()
        self._readycallback = readycallback
        self._userdata = userdata
        self._resolver = GetURLTitleThread(url, self._queue)
        self._resolver.start()

    def _is_ready(self):
        return not self._queue.empty()

    def prepare(self, *args):
        return (self._is_ready(), 10)

    def check(self, *args):
        return self._is_ready()

    def dispatch(self, *args):
        if not self._is_ready():
            raise RuntimeError(
                "GetURLHTMLTitleThreadSource.dispatch()"
                " called but result is not ready yet, or already consumed.")

        # An attempty to destroy the resolver's thread ASAP
        self._resolver = None

        self._readycallback(self._queue.get(), self._userdata)

        # Destroy this source
        return False

    def finalize(self, *args):
        pass
예제 #4
0
class GetURLTitleThreadSource(GLib.Source):
    """Runs thread and waits until the thread does not return the url's title
    """

    #pylint: disable=W0613
    def __new__(cls, *args):
        return GLib.Source.__new__(cls)

    def __init__(self, url, readycallback, userdata):
        GLib.Source.__init__(self)

        self._queue = Queue()
        self._readycallback = readycallback
        self._userdata = userdata
        self._resolver = GetURLTitleThread(url, self._queue)
        self._resolver.start()

    def _is_ready(self):
        return not self._queue.empty()

    def prepare(self, *args):
        return (self._is_ready(), 10)

    def check(self, *args):
        return self._is_ready()

    def dispatch(self, *args):
        if not self._is_ready():
            raise RuntimeError("GetURLHTMLTitleThreadSource.dispatch()"
            " called but result is not ready yet, or already consumed.")

        # An attempty to destroy the resolver's thread ASAP
        self._resolver = None

        self._readycallback(self._queue.get(), self._userdata)

        # Destroy this source
        return False

    def finalize(self, *args):
        pass