How to use the greenlet.greenlet.__init__ function in greenlet

To help you get started, we’ve selected a few greenlet 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 wwqgtxx / wwqLyParse / wwqLyParse / lib / python-3.7.2-embed-amd64 / gevent / _greenlet_primitives.py View on Github external
def __init__(self, function, parent):
        greenlet.__init__(self, function, parent)
        # See greenlet.py's Greenlet class. We capture the cheap
        # parts to maintain the tree structure, but we do not capture
        # the stack because that's too expensive for 'spawn_raw'.

        current = getcurrent() # pylint:disable=undefined-variable
        self.spawning_greenlet = wref(current)
        # See Greenlet for how trees are maintained.
        try:
            self.spawn_tree_locals = current.spawn_tree_locals
        except AttributeError:
            self.spawn_tree_locals = {}
            if current.parent:
                current.spawn_tree_locals = self.spawn_tree_locals
github bogdanvuk / sydpy / sydpy / simulator.py View on Github external
def __init__(self, log_task_switching = False):
        greenlet.__init__(self)
        if log_task_switching:
            self.settrace(self.callback)
github KevinOConnor / klipper / klippy / reactor.py View on Github external
def __init__(self, run):
        greenlet.greenlet.__init__(self, run=run)
        self.timer = None
github bogdanvuk / sydpy / sydpy / _process.py View on Github external
self.module.proc_reg(self)
        self.name = module.qualified_name + "." + func.__name__
        senslist = []
        
        for a in args:
            if hasattr(a, 'subscribe'):
                senslist.append(a)
        
        self.senslist = senslist
        self._exit_func = exit_func
        
        # If the module is to be traslated to HDL, translate the process
        if module.hdl_gen:
            self.hdl_gen()
        
        greenlet.__init__(self)
github gevent / gevent / src / gevent / greenlet.py View on Github external
# meaning we wind up boxing the f_lineno just to unbox it if we pass it.
        # It's faster to simply assign once the object is created.
        older_Frame.f_code = frame.f_code
        older_Frame.f_lineno = get_f_lineno(frame) # pylint:disable=undefined-variable
        if newer_Frame is not None:
            newer_Frame.f_back = older_Frame
        newer_Frame = older_Frame
        if newest_Frame is None:
            newest_Frame = newer_Frame

        frame = get_f_back(frame) # pylint:disable=undefined-variable

    return newest_Frame


_greenlet__init__ = greenlet.__init__

class Greenlet(greenlet):
    """
    A light-weight cooperatively-scheduled execution unit.
    """
    # pylint:disable=too-many-public-methods,too-many-instance-attributes

    spawning_stack_limit = 10

    # pylint:disable=keyword-arg-before-vararg,super-init-not-called
    def __init__(self, run=None, *args, **kwargs):
        """
        :param args: The arguments passed to the ``run`` function.
        :param kwargs: The keyword arguments passed to the ``run`` function.
        :keyword callable run: The callable object to run. If not given, this object's
            `_run` method will be invoked (typically defined by subclasses).
github gevent / gevent / src / gevent / _greenlet_primitives.py View on Github external
def __init__(self, function, parent):
        greenlet.__init__(self, function, parent)
        # See greenlet.py's Greenlet class. We capture the cheap
        # parts to maintain the tree structure, but we do not capture
        # the stack because that's too expensive for 'spawn_raw'.

        current = getcurrent() # pylint:disable=undefined-variable
        self.spawning_greenlet = wref(current)
        # See Greenlet for how trees are maintained.
        try:
            self.spawn_tree_locals = current.spawn_tree_locals
        except AttributeError:
            self.spawn_tree_locals = {}
            if current.parent:
                current.spawn_tree_locals = self.spawn_tree_locals
github gdeetotdom / thriftworker / thriftworker / hub.py View on Github external
def __init__(self, hub, run=None, *args, **kwargs):
        greenlet.__init__(self, parent=hub._greenlet)
        if run is not None:
            self._run = run
        self.hub = hub
        self.args = args
        self.kwargs = kwargs
        self._links = deque()
        self.value = None
        self._exception = _NONE
        self._notifier = None
        self._start_event = None
github kenorb-contrib / BitTorrent / B / BTL / greenlet_yielddefer.py View on Github external
def __init__(self, root, df, _f, *a, **kw):
        self.root = root
        self.yielded_once = False
        self.finished = False
        greenlet.greenlet.__init__(self,
                                   lambda : self.body(df, _f, *a, **kw))
github veegee / guv / guv / greenthread.py View on Github external
def __init__(self, parent):
        """
        :param parent: parent greenlet
        :type parent: greenlet.greenlet
        """
        greenlet.greenlet.__init__(self, self.main, parent)
        self._exit_event = event.Event()
        self._resolving_links = False