Example #1
0
    def __init__(self, loop=None, default=None):
        WaitOperationsGreenlet.__init__(self, None, None)
        self.thread_ident = get_thread_ident()
        if hasattr(loop, 'run'):
            if default is not None:
                raise TypeError("Unexpected argument: default")
            self.loop = loop
        elif get_loop() is not None:
            # Reuse a loop instance previously set by
            # destroying a hub without destroying the associated
            # loop. See #237 and #238.
            self.loop = get_loop()
        else:
            if default is None and self.thread_ident != MAIN_THREAD_IDENT:
                default = False

            if loop is None:
                loop = self.backend
            self.loop = self.loop_class(flags=loop, default=default)  # pylint:disable=not-callable
        self._resolver = None
        self._threadpool = None
        self.format_context = GEVENT_CONFIG.format_context

        Hub._hub_counter += 1
        self.minimal_ident = Hub._hub_counter
Example #2
0
File: hub.py Project: gevent/gevent
    def __init__(self, loop=None, default=None):
        WaitOperationsGreenlet.__init__(self, None, None)
        self.thread_ident = get_thread_ident()
        if hasattr(loop, 'run'):
            if default is not None:
                raise TypeError("Unexpected argument: default")
            self.loop = loop
        elif get_loop() is not None:
            # Reuse a loop instance previously set by
            # destroying a hub without destroying the associated
            # loop. See #237 and #238.
            self.loop = get_loop()
        else:
            if default is None and self.thread_ident != MAIN_THREAD_IDENT:
                default = False

            if loop is None:
                loop = self.backend
            self.loop = self.loop_class(flags=loop, default=default) # pylint:disable=not-callable
        self._resolver = None
        self._threadpool = None
        self.format_context = GEVENT_CONFIG.format_context

        Hub._hub_counter += 1
        self.minimal_ident = Hub._hub_counter