gevent API Reference

Coroutine-based Python networking library that uses greenlets and libev.

gevent.Greenlet
Python Library Documentation: class Greenlet in module gevent._gevent_cgreenlet

class Greenlet(greenlet.greenlet)
 |  Greenlet(run=None, *args, **kwargs)
 |
 |  A light-weight cooperatively-scheduled execution unit.
 |
 |  Method resolution order:
 |      Greenlet
 |      greenlet.greenlet
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __bool__(self, /)
 |      True if self else False
 |
 |  __enter__(self)
 |      Greenlet.__enter__(self)
 |
 |  __exit__(self, t, v, tb)
 |      Greenlet.__exit__(self, t, v, tb)
 |
 |  __init__(...)
 |      :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).
 |
 |      .. versionchanged:: 1.1b1
 |          The ``run`` argument to the constructor is now verified to be a callable
 |          object. Previously, passing a non-callable object would fail after the greenlet
 |          was spawned.
 |
 |      .. versionchanged:: 1.3b1
 |         The ``GEVENT_TRACK_GREENLET_TREE`` configuration value may be set to
 |         a false value to disable ``spawn_tree_locals``, ``spawning_greenlet``,
 |         and ``spawning_stack``. The first two will be None in that case, and the
 |         latter will be empty.
 |
 |      .. versionchanged:: 1.5
 |         Greenlet objects are now more careful to verify that their ``parent`` is really
 |         a gevent hub, raising a ``TypeError`` earlier instead of an ``AttributeError`` later.
 |
 |      .. versionchanged:: 20.12.1
 |         Greenlet objects now function as context managers. Exiting the ``with`` suite
 |         ensures that the greenlet has completed by :meth:`joining <join>`
 |         the greenlet (blocking, with
 |         no timeout). If the body of the suite raises an exception, the greenlet is
 |         :meth:`killed <kill>` with the default arguments and not joined in that case.
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  get(self, block=True, timeout=None)
 |      Greenlet.get(self, block=True, timeout=None)
 |
 |      get(block=True, timeout=None) -> object
 |
 |      Return the result the greenlet has returned or re-raise the
 |      exception it has raised.
 |
 |      If block is ``False``, raise :class:`gevent.Timeout` if the
 |      greenlet is still alive. If block is ``True``, unschedule the
 |      current greenlet until the result is available or the timeout
 |      expires. In the latter case, :class:`gevent.Timeout` is
 |      raised.
 |
 |  has_links(self)
 |      Greenlet.has_links(self) -> bool
 |
 |  join(self, timeout=None)
 |      Greenlet.join(self, timeout=None)
 |
 |      join(timeout=None) -> None
 |
 |      Wait until the greenlet finishes or *timeout* expires. Return
 |      ``None`` regardless.
 |
 |  kill(self, exception=<class 'greenlet.GreenletExit'>, block=True, timeout=None)
 |      Greenlet.kill(self, exception=GreenletExit, block=True, timeout=None)
 |
 |      Raise the ``exception`` in the greenlet.
 |
 |      If ``block`` is ``True`` (the default), wait until the greenlet
 |      dies or the optional timeout expires; this may require switching
 |      greenlets.
 |      If block is ``False``, the current greenlet is not unscheduled.
 |
 |      This function always returns ``None`` and never raises an error. It
 |      may be called multpile times on the same greenlet object, and may be
 |      called on an unstarted or dead greenlet.
 |
 |      .. note::
 |
 |          Depending on what this greenlet is executing and the state
 |          of the event loop, the exception may or may not be raised
 |          immediately when this greenlet resumes execution. It may
 |          be raised on a subsequent green call, or, if this greenlet
 |          exits before making such a call, it may not be raised at
 |          all. As of 1.1, an example where the exception is raised
 |          later is if this greenlet had called :func:`sleep(0)
 |          <gevent.sleep>`; an example where the exception is raised
 |          immediately is if this greenlet had called
 |          :func:`sleep(0.1) <gevent.sleep>`.
 |
 |      .. caution::
 |
 |          Use care when killing greenlets. If the code executing is not
 |          exception safe (e.g., makes proper use of ``finally``) then an
 |          unexpected exception could result in corrupted state. Using
 |          a :meth:`link` or :meth:`rawlink` (cheaper) may be a safer way to
 |          clean up resources.
 |
 |      See also :func:`gevent.kill` and :func:`gevent.killall`.
 |
 |      :keyword type exception: The type of exception to raise in the greenlet. The default
 |          is :class:`GreenletExit`, which indicates a :meth:`successful` completion
 |          of the greenlet.
 |
 |      .. versionchanged:: 0.13.0
 |          *block* is now ``True`` by default.
 |      .. versionchanged:: 1.1a2
 |          If this greenlet had never been switched to, killing it will
 |          prevent it from *ever* being switched to. Links (:meth:`rawlink`)
 |          will still be executed, though.
 |      .. versionchanged:: 20.12.1
 |          If this greenlet is :meth:`ready`, immediately return instead of
 |          requiring a trip around the event loop.
 |
 |  link(self, callback, SpawnedLink=<class 'gevent._gevent_cgreenlet.SpawnedLink'>)
 |      Greenlet.link(self, callback, SpawnedLink=SpawnedLink)
 |
 |      Link greenlet's completion to a callable.
 |
 |      The *callback* will be called with this instance as an
 |      argument once this greenlet is dead. A callable is called in
 |      its own :class:`greenlet.greenlet` (*not* a
 |      :class:`Greenlet`).
 |
 |      The *callback* will be called even if linked after the greenlet
 |      is already ready().
 |
 |  link_exception(self, callback, SpawnedLink=<class 'gevent._gevent_cgreenlet.FailureSpawnedLink'>)
 |      Greenlet.link_exception(self, callback, SpawnedLink=FailureSpawnedLink)
 |
 |      Like :meth:`link` but *callback* is only notified when the
 |      greenlet dies because of an unhandled exception.
 |
 |  link_value(self, callback, SpawnedLink=<class 'gevent._gevent_cgreenlet.SuccessSpawnedLink'>)
 |      Greenlet.link_value(self, callback, SpawnedLink=SuccessSpawnedLink)
 |
 |      Like :meth:`link` but *callback* is only notified when the greenlet
 |      has completed successfully.
 |
 |  name(...)
 |      Greenlet.name(self)
 |
 |      The greenlet name. By default, a unique name is constructed using
 |      the :attr:`minimal_ident`. You can assign a string to this
 |      value to change it. It is shown in the `repr` of this object if it
 |      has been assigned to or if the `minimal_ident` has already been generated.
 |
 |      .. versionadded:: 1.3a2
 |      .. versionchanged:: 1.4
 |         Stop showing generated names in the `repr` when the ``minimal_ident``
 |         hasn't been requested. This reduces overhead and may be less confusing,
 |         since ``minimal_ident`` can get reused.
 |
 |  rawlink(self, callback)
 |      Greenlet.rawlink(self, callback)
 |
 |      Register a callable to be executed when the greenlet finishes
 |      execution.
 |
 |      The *callback* will be called with this instance as an
 |      argument.
 |
 |      The *callback* will be called even if linked after the greenlet
 |      is already ready().
 |
 |      .. caution::
 |          The *callback* will be called in the hub and
 |          **MUST NOT** raise an exception.
 |
 |  ready(self)
 |      Greenlet.ready(self) -> bool
 |
 |      Return a true value if and only if the greenlet has finished
 |      execution.
 |
 |      .. versionchanged:: 1.1
 |          This function is only guaranteed to return true or false *values*, not
 |          necessarily the literal constants ``True`` or ``False``.
 |
 |  run(self)
 |      Greenlet.run(self)
 |
 |  start(self)
 |      Greenlet.start(self)
 |
 |      Schedule the greenlet to run in this loop iteration
 |
 |  start_later(self, seconds)
 |      Greenlet.start_later(self, seconds)
 |
 |      start_later(seconds) -> None
 |
 |      Schedule the greenlet to run in the future loop iteration
 |      *seconds* later
 |
 |  successful(self)
 |      Greenlet.successful(self) -> bool
 |
 |      Return a true value if and only if the greenlet has finished execution
 |      successfully, that is, without raising an error.
 |
 |      .. tip:: A greenlet that has been killed with the default
 |          :class:`GreenletExit` exception is considered successful.
 |          That is, ``GreenletExit`` is not considered an error.
 |
 |      .. note:: This function is only guaranteed to return true or false *values*,
 |            not necessarily the literal constants ``True`` or ``False``.
 |
 |  throw(self, *args)
 |      Greenlet.throw(self, *args)
 |
 |      Immediately switch into the greenlet and raise an exception in it.
 |
 |      Should only be called from the HUB, otherwise the current greenlet is left unscheduled forever.
 |      To raise an exception in a safe manner from any greenlet, use :meth:`kill`.
 |
 |      If a greenlet was started but never switched to yet, then also
 |      a) cancel the event that will start it
 |      b) fire the notifications as if an exception was raised in a greenlet
 |
 |  unlink(self, callback)
 |      Greenlet.unlink(self, callback)
 |
 |      Remove the callback set by :meth:`link` or :meth:`rawlink`
 |
 |  unlink_all(self)
 |      Greenlet.unlink_all(self)
 |
 |      Remove all the callbacks.
 |
 |      .. versionadded:: 1.3a2
 |
 |  ----------------------------------------------------------------------
 |  Class methods defined here:
 |
 |  spawn(*args, **kwargs)
 |      Greenlet.spawn(cls, *args, **kwargs)
 |
 |      spawn(function, *args, **kwargs) -> Greenlet
 |
 |      Create a new :class:`Greenlet` object and schedule it to run ``function(*args, **kwargs)``.
 |      This can be used as ``gevent.spawn`` or ``Greenlet.spawn``.
 |
 |      The arguments are passed to :meth:`Greenlet.__init__`.
 |
 |      .. versionchanged:: 1.1b1
 |          If a *function* is given that is not callable, immediately raise a :exc:`TypeError`
 |          instead of spawning a greenlet that will raise an uncaught TypeError.
 |
 |  spawn_later(seconds, *args, **kwargs)
 |      Greenlet.spawn_later(cls, seconds, *args, **kwargs)
 |
 |      spawn_later(seconds, function, *args, **kwargs) -> Greenlet
 |
 |      Create and return a new `Greenlet` object scheduled to run ``function(*args, **kwargs)``
 |      in a future loop iteration *seconds* later. This can be used as ``Greenlet.spawn_later``
 |      or ``gevent.spawn_later``.
 |
 |      The arguments are passed to :meth:`Greenlet.__init__`.
 |
 |      .. versionchanged:: 1.1b1
 |         If an argument that's meant to be a function (the first argument in *args*, or the ``run`` keyword )
 |         is given to this classmethod (and not a classmethod of a subclass),
 |         it is verified to be callable. Previously, the spawned greenlet would have failed
 |         when it started running.
 |
 |  ----------------------------------------------------------------------
 |  Static methods defined here:
 |
 |  __new__(*args, **kwargs)
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  add_spawn_callback(callback)
 |      Greenlet.add_spawn_callback(callback)
 |
 |      add_spawn_callback(callback) -> None
 |
 |      Set up a *callback* to be invoked when :class:`Greenlet` objects
 |      are started.
 |
 |      The invocation order of spawn callbacks is unspecified.  Adding the
 |      same callback more than one time will not cause it to be called more
 |      than once.
 |
 |      .. versionadded:: 1.4.0
 |
 |  remove_spawn_callback(callback)
 |      Greenlet.remove_spawn_callback(callback)
 |
 |      remove_spawn_callback(callback) -> None
 |
 |      Remove *callback* function added with :meth:`Greenlet.add_spawn_callback`.
 |      This function will not fail if *callback* has been already removed or
 |      if *callback* was never added.
 |
 |      .. versionadded:: 1.4.0
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  args
 |
 |  dead
 |      Boolean indicating that the greenlet is dead and will not run again.
 |
 |      This is true if:
 |
 |      1. We were never started, but were :meth:`killed <kill>`
 |         immediately after creation (not possible with :meth:`spawn`); OR
 |      2. We were started, but were killed before running; OR
 |      3. We have run and terminated (by raising an exception out of the
 |         started function or by reaching the end of the started function).
 |
 |  exc_info
 |      Holds the exc_info three-tuple raised by the function if the
 |      greenlet finished with an error. Otherwise a false value.
 |
 |      .. note:: This is a provisional API and may change.
 |
 |      .. versionadded:: 1.1
 |
 |  exception
 |      Holds the exception instance raised by the function if the
 |      greenlet has finished with an error. Otherwise ``None``.
 |
 |  kwargs
 |
 |  loop
 |
 |  minimal_ident
 |      A small, unique non-negative integer that identifies this object.
 |
 |      This is similar to :attr:`threading.Thread.ident` (and `id`)
 |      in that as long as this object is alive, no other greenlet *in
 |      this hub* will have the same id, but it makes a stronger
 |      guarantee that the assigned values will be small and
 |      sequential. Sometime after this object has died, the value
 |      will be available for reuse.
 |
 |      To get ids that are unique across all hubs, combine this with
 |      the hub's (``self.parent``) ``minimal_ident``.
 |
 |      Accessing this property from threads other than the thread running
 |      this greenlet is not defined.
 |
 |      .. versionadded:: 1.3a2
 |
 |  spawn_tree_locals
 |      spawn_tree_locals: dict
 |
 |  spawning_greenlet
 |
 |  spawning_stack
 |
 |  started
 |
 |  value
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes defined here:
 |
 |  __pyx_vtable__ = <capsule object NULL>
 |
 |  spawning_stack_limit = 10
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from greenlet.greenlet:
 |
 |  __getstate__(...)
 |      Helper for pickle.
 |
 |  switch(...)
 |      switch(*args, **kwargs)
 |
 |      Switch execution to this greenlet.
 |
 |      If this greenlet has never been run, then this greenlet
 |      will be switched to using the body of ``self.run(*args, **kwargs)``.
 |
 |      If the greenlet is active (has been run, but was switch()'ed
 |      out before leaving its run function), then this greenlet will
 |      be resumed and the return value to its switch call will be
 |      None if no arguments are given, the given argument if one
 |      argument is given, or the args tuple and keyword args dict if
 |      multiple arguments are given.
 |
 |      If the greenlet is dead, or is the current greenlet then this
 |      function will simply return the arguments using the same rules as
 |      above.
 |
 |  ----------------------------------------------------------------------
 |  Static methods inherited from greenlet.greenlet:
 |
 |  getcurrent(...)
 |      getcurrent() -> greenlet
 |
 |      Returns the current greenlet (i.e. the one which called this function).
 |
 |  gettrace(...)
 |      gettrace() -> object
 |
 |      Returns the currently set tracing function, or None.
 |
 |  settrace(...)
 |      settrace(callback) -> object
 |
 |      Sets a new tracing function and returns the previous one.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from greenlet.greenlet:
 |
 |  __dict__
 |
 |  gr_context
 |
 |  gr_frame
 |
 |  parent
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes inherited from greenlet.greenlet:
 |
 |  GreenletExit = <class 'greenlet.GreenletExit'>
 |
 |  error = <class 'greenlet.error'>
gevent.GreenletExit
Python Library Documentation: class GreenletExit in module greenlet

class GreenletExit(builtins.BaseException)
 |  Method resolution order:
 |      GreenletExit
 |      builtins.BaseException
 |      builtins.object
 |
 |  Data descriptors defined here:
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from builtins.BaseException:
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __init__(self, /, *args, **kwargs)
 |      Initialize self.  See help(type(self)) for accurate signature.
 |
 |  __reduce__(...)
 |      Helper for pickle.
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __setstate__(...)
 |
 |  __str__(self, /)
 |      Return str(self).
 |
 |  add_note(...)
 |      Exception.add_note(note) --
 |      add a note to the exception
 |
 |  with_traceback(...)
 |      Exception.with_traceback(tb) --
 |      set self.__traceback__ to tb and return self.
 |
 |  ----------------------------------------------------------------------
 |  Static methods inherited from builtins.BaseException:
 |
 |  __new__(*args, **kwargs) class method of builtins.BaseException
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from builtins.BaseException:
 |
 |  __cause__
 |      exception cause
 |
 |  __context__
 |      exception context
 |
 |  __dict__
 |
 |  __suppress_context__
 |
 |  __traceback__
 |
 |  args
gevent.Timeout
Python Library Documentation: class Timeout in module gevent.timeout

class Timeout(builtins.BaseException)
 |  Timeout(seconds=None, exception=None, ref=True, priority=-1, _one_shot=False)
 |
 |  Timeout(seconds=None, exception=None, ref=True, priority=-1)
 |
 |  Raise *exception* in the current greenlet after *seconds*
 |  have elapsed::
 |
 |      timeout = Timeout(seconds, exception)
 |      timeout.start()
 |      try:
 |          ...  # exception will be raised here, after *seconds* passed since start() call
 |      finally:
 |          timeout.close()
 |
 |  .. warning::
 |
 |      You must **always** call `close` on a ``Timeout`` object you have created,
 |      whether or not the code that the timeout was protecting finishes
 |      executing before the timeout elapses (whether or not the
 |      ``Timeout`` exception is raised)  This ``try/finally``
 |      construct or a ``with`` statement is a good pattern. (If
 |      the timeout object will be started again, use `cancel` instead
 |      of `close`; this is rare. You must still `close` it when you are
 |      done.)
 |
 |  When *exception* is omitted or ``None``, the ``Timeout`` instance
 |  itself is raised::
 |
 |      >>> import gevent
 |      >>> gevent.Timeout(0.1).start()
 |      >>> gevent.sleep(0.2)  #doctest: +IGNORE_EXCEPTION_DETAIL
 |      Traceback (most recent call last):
 |       ...
 |      Timeout: 0.1 seconds
 |
 |  If the *seconds* argument is not given or is ``None`` (e.g.,
 |  ``Timeout()``), then the timeout will never expire and never raise
 |  *exception*. This is convenient for creating functions which take
 |  an optional timeout parameter of their own. (Note that this is **not**
 |  the same thing as a *seconds* value of ``0``.)
 |
 |  ::
 |
 |     def function(args, timeout=None):
 |        "A function with an optional timeout."
 |        timer = Timeout(timeout)
 |        with timer:
 |           ...
 |
 |  .. caution::
 |
 |      A *seconds* value less than ``0.0`` (e.g., ``-1``) is poorly defined. In the future,
 |      support for negative values is likely to do the same thing as a value
 |      of ``None`` or ``0``
 |
 |  A *seconds* value of ``0`` requests that the event loop spin and poll for I/O;
 |  it will immediately expire as soon as control returns to the event loop.
 |
 |  .. rubric:: Use As A Context Manager
 |
 |  To simplify starting and canceling timeouts, the ``with``
 |  statement can be used::
 |
 |      with gevent.Timeout(seconds, exception) as timeout:
 |          pass  # ... code block ...
 |
 |  This is equivalent to the try/finally block above with one
 |  additional feature: if *exception* is the literal ``False``, the
 |  timeout is still raised, but the context manager suppresses it, so
 |  the code outside the with-block won't see it.
 |
 |  This is handy for adding a timeout to the functions that don't
 |  support a *timeout* parameter themselves::
 |
 |      data = None
 |      with gevent.Timeout(5, False):
 |          data = mysock.makefile().readline()
 |      if data is None:
 |          ...  # 5 seconds passed without reading a line
 |      else:
 |          ...  # a line was read within 5 seconds
 |
 |  .. caution::
 |
 |      If ``readline()`` above catches and doesn't re-raise
 |      :exc:`BaseException` (for example, with a bare ``except:``), then
 |      your timeout will fail to function and control won't be returned
 |      to you when you expect.
 |
 |  .. rubric:: Catching Timeouts
 |
 |  When catching timeouts, keep in mind that the one you catch may
 |  not be the one you have set (a calling function may have set its
 |  own timeout); if you are going to silence a timeout, always check that
 |  it's the instance you need::
 |
 |      timeout = Timeout(1)
 |      timeout.start()
 |      try:
 |          ...
 |      except Timeout as t:
 |          if t is not timeout:
 |              raise # not my timeout
 |      finally:
 |          timeout.close()
 |
 |
 |  .. versionchanged:: 1.1b2
 |
 |      If *seconds* is not given or is ``None``, no longer allocate a
 |      native timer object that will never be started.
 |
 |  .. versionchanged:: 1.1
 |
 |      Add warning about negative *seconds* values.
 |
 |  .. versionchanged:: 1.3a1
 |
 |      Timeout objects now have a :meth:`close`
 |      method that *must* be called when the timeout will no longer be
 |      used to properly clean up native resources.
 |      The ``with`` statement does this automatically.
 |
 |  .. versionchanged:: 24.10.1
 |
 |        Timeout values can be compared to be less than an integer value,
 |        or to be less than other timeouts, e.g., ``Timeout(0) < 1`` is true.
 |        Timeouts are not absolutely ordered and support no other comparisons; this
 |        is purely for convenience and may be removed or altered in the future.
 |
 |  Method resolution order:
 |      Timeout
 |      builtins.BaseException
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __enter__(self)
 |      Start and return the timer. If the timer is already started, just return it.
 |
 |  __exit__(self, typ, value, tb)
 |      Stop the timer.
 |
 |      .. versionchanged:: 1.3a1
 |         The underlying native timer is also stopped. This object cannot be
 |         used again.
 |
 |  __init__(self, seconds=None, exception=None, ref=True, priority=-1, _one_shot=False)
 |      Initialize self.  See help(type(self)) for accurate signature.
 |
 |  __lt__(self, other)
 |      For convenience, timeouts can be compared to integers (numbers)
 |      based on their seconds value.
 |
 |  __repr__(self)
 |      Return repr(self).
 |
 |  __str__(self)
 |      >>> raise Timeout #doctest: +IGNORE_EXCEPTION_DETAIL
 |      Traceback (most recent call last):
 |          ...
 |      Timeout
 |
 |  cancel(self)
 |      If the timeout is pending, cancel it. Otherwise, do nothing.
 |
 |      The timeout object can be :meth:`started <start>` again. If
 |      you will not start the timeout again, you should use
 |      :meth:`close` instead.
 |
 |  close(self)
 |      Close the timeout and free resources. The timer cannot be started again
 |      after this method has been used.
 |
 |  start(self)
 |      Schedule the timeout.
 |
 |  ----------------------------------------------------------------------
 |  Class methods defined here:
 |
 |  start_new(timeout=None, exception=None, ref=True, _one_shot=False)
 |      Create a started :class:`Timeout`.
 |
 |      This is a shortcut, the exact action depends on *timeout*'s type:
 |
 |      * If *timeout* is a :class:`Timeout`, then call its :meth:`start` method
 |        if it's not already begun.
 |      * Otherwise, create a new :class:`Timeout` instance, passing (*timeout*, *exception*) as
 |        arguments, then call its :meth:`start` method.
 |
 |      Returns the :class:`Timeout` instance.
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties defined here:
 |
 |  pending
 |      True if the timeout is scheduled to be raised.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from builtins.BaseException:
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __reduce__(...)
 |      Helper for pickle.
 |
 |  __setstate__(...)
 |
 |  add_note(...)
 |      Exception.add_note(note) --
 |      add a note to the exception
 |
 |  with_traceback(...)
 |      Exception.with_traceback(tb) --
 |      set self.__traceback__ to tb and return self.
 |
 |  ----------------------------------------------------------------------
 |  Static methods inherited from builtins.BaseException:
 |
 |  __new__(*args, **kwargs) class method of builtins.BaseException
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from builtins.BaseException:
 |
 |  __cause__
 |      exception cause
 |
 |  __context__
 |      exception context
 |
 |  __dict__
 |
 |  __suppress_context__
 |
 |  __traceback__
 |
 |  args
gevent.absolute_import
Python Library Documentation: _Feature in module __future__ object

class _Feature(builtins.object)
 |  _Feature(optionalRelease, mandatoryRelease, compiler_flag)
 |
 |  Methods defined here:
 |
 |  __init__(self, optionalRelease, mandatoryRelease, compiler_flag)
 |      Initialize self.  See help(type(self)) for accurate signature.
 |
 |  __repr__(self)
 |      Return repr(self).
 |
 |  getMandatoryRelease(self)
 |      Return release in which this feature will become mandatory.
 |
 |      This is a 5-tuple, of the same form as sys.version_info, or, if
 |      the feature was dropped, or the release date is undetermined, is None.
 |
 |  getOptionalRelease(self)
 |      Return first release in which this feature was recognized.
 |
 |      This is a 5-tuple, of the same form as sys.version_info.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
gevent.config
Python Library Documentation: Config in module gevent._config object

class Config(builtins.object)
 |  Global configuration for gevent.
 |
 |  There is one instance of this object at ``gevent.config``. If you
 |  are going to make changes in code, instead of using the documented
 |  environment variables, you need to make the changes before using
 |  any parts of gevent that might need those settings (unless otherwise
 |  documented). For example::
 |
 |      >>> from gevent import config
 |      >>> config.fileobject = 'thread'
 |
 |      >>> from gevent import fileobject
 |      >>> fileobject.FileObject.__name__
 |      'FileObjectThread'
 |
 |  .. versionadded:: 1.3a2
 |
 |  Methods defined here:
 |
 |  __dir__(self)
 |      Default dir() implementation.
 |
 |  __getattr__(self, name)
 |
 |  __init__(self)
 |      Initialize self.  See help(type(self)) for accurate signature.
 |
 |  __setattr__(self, name, value)
 |      Implement setattr(self, name, value).
 |
 |  print_help(self)
 |
 |  set(self, name, value)
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ares_servers
 |      A list of strings giving the IP addresses of nameservers for the ares resolver.
 |
 |      In the environment variable, these strings are separated by commas.
 |
 |      .. deprecated:: 1.3a2
 |         Prefer the :attr:`resolver_nameservers` setting. If both are set,
 |         the results are not defined.
 |
 |      The default value is `None`
 |
 |      The environment variable ``GEVENTARES_SERVERS`` can be used to control this.
 |
 |  ares_timeout
 |      .. deprecated:: 1.3a2
 |         Prefer the :attr:`resolver_timeout` setting. If both are set,
 |         the results are not defined.
 |
 |      The default value is `None`
 |
 |      The environment variable ``GEVENTARES_TIMEOUT`` can be used to control this.
 |
 |  disable_watch_children
 |      Should we *not* watch children with the event loop watchers?
 |
 |      This is an advanced setting.
 |
 |      See :mod:`gevent.os` for a detailed description.
 |
 |      This is a boolean value.
 |
 |      In the environment variable, it may be given as ``1``, ``true``,
 |      ``on`` or ``yes`` for `True`, or ``0``, ``false``, ``off``, or
 |      ``no`` for `False`.
 |
 |      The default value is `False`
 |
 |      The environment variable ``GEVENT_NOWAITPID`` can be used to control this.
 |
 |  fileobject
 |      The kind of ``FileObject`` we will use.
 |
 |      See :mod:`gevent.fileobject` for a detailed description.
 |
 |      This is an importable value. It can be given as a string naming an importable object, or a list of strings in preference order and the first successfully importable object will be used. (Separate values in the environment variable with commas.) It can also be given as the callable object itself (in code). Shorthand names for default objects are ['thread', 'posix', 'block']
 |
 |      The default value is `['posix', 'thread']`
 |
 |      The environment variable ``GEVENT_FILE`` can be used to control this.
 |
 |  format_context
 |      This is an importable value. It can be given as a string naming an importable object, or a list of strings in preference order and the first successfully importable object will be used. (Separate values in the environment variable with commas.) It can also be given as the callable object itself (in code).
 |
 |      The default value is `pprint.saferepr`
 |
 |      The environment variable ``GEVENT_FORMAT_CONTEXT`` can be used to control this.
 |
 |  libev_backend
 |      The backend for libev, such as 'select'
 |
 |      The default value is `None`
 |
 |      The environment variable ``GEVENT_BACKEND`` can be used to control this.
 |
 |  loop
 |      The kind of the loop we use.
 |
 |      On Windows, this defaults to libuv, while on
 |      other platforms it defaults to libev.
 |
 |      This is an importable value. It can be given as a string naming an importable object, or a list of strings in preference order and the first successfully importable object will be used. (Separate values in the environment variable with commas.) It can also be given as the callable object itself (in code). Shorthand names for default objects are ['libev-cext', 'libev-cffi', 'libuv-cffi', 'libuv']
 |
 |      The default value is `['libuv-cffi', 'libev-cext', 'libev-cffi']`
 |
 |      The environment variable ``GEVENT_LOOP`` can be used to control this.
 |
 |  max_blocking_time
 |      If the `monitor_thread` is enabled, this is
 |      approximately how long (in seconds)
 |      the event loop will be allowed to block before a warning is issued.
 |
 |      This function depends on using `greenlet.settrace`, so installing
 |      your own trace function after starting the monitoring thread will
 |      cause this feature to misbehave unless you call the function
 |      returned by `greenlet.settrace`. If you install a tracing function *before*
 |      the monitoring thread is started, it will still be called.
 |
 |      .. note:: In the unlikely event of creating and using multiple different
 |          gevent hubs in the same native thread in a short period of time,
 |          especially without destroying the hubs, false positives may be reported.
 |
 |      .. versionadded:: 1.3b1
 |
 |      The default value is `0.1`
 |
 |      The environment variable ``GEVENT_MAX_BLOCKING_TIME`` can be used to control this.
 |
 |  max_memory_usage
 |      If `monitor_thread` is enabled,
 |      then if memory usage exceeds this amount (in bytes), events will
 |      be emitted. See `gevent.events`. In the environment variable, you can use
 |      a suffix of 'kb', 'mb' or 'gb' to specify the value in kilobytes, megabytes
 |      or gigibytes.
 |
 |      There is no default value for this setting. If you wish to
 |      cap memory usage, you must choose a value.
 |
 |      The default value is `None`
 |
 |      The environment variable ``GEVENT_MONITOR_MEMORY_MAX`` can be used to control this.
 |
 |  memory_monitor_period
 |      If `monitor_thread` is enabled, this is approximately how long
 |      (in seconds) we will go between checking the processes memory usage.
 |
 |      Checking the memory usage is relatively expensive on some operating
 |      systems, so this should not be too low. gevent will place a floor
 |      value on it.
 |
 |      The default value is `5`
 |
 |      The environment variable ``GEVENT_MONITOR_MEMORY_PERIOD`` can be used to control this.
 |
 |  monitor_thread
 |      Should each hub start a native OS thread to monitor
 |      for problems?
 |
 |      Such a thread will periodically check to see if the event loop
 |      is blocked for longer than `max_blocking_time`, producing output on
 |      the hub's exception stream (stderr by default) if it detects this condition.
 |
 |      If this setting is true, then this thread will be created
 |      the first time the hub is switched to,
 |      or you can call :meth:`gevent.hub.Hub.start_periodic_monitoring_thread` at any
 |      time to create it (from the same thread that will run the hub). That function
 |      will return an instance of :class:`gevent.events.IPeriodicMonitorThread`
 |      to which you can add your own monitoring functions. That function
 |      also emits an event of :class:`gevent.events.PeriodicMonitorThreadStartedEvent`.
 |
 |      .. seealso:: `max_blocking_time`
 |
 |      .. versionadded:: 1.3b1
 |
 |      This is a boolean value.
 |
 |      In the environment variable, it may be given as ``1``, ``true``,
 |      ``on`` or ``yes`` for `True`, or ``0``, ``false``, ``off``, or
 |      ``no`` for `False`.
 |
 |      The default value is `False`
 |
 |      The environment variable ``GEVENT_MONITOR_THREAD_ENABLE`` can be used to control this.
 |
 |  print_blocking_reports
 |      If `monitor_thread` is enabled, and gevent detects a hub blocked
 |      for more than `max_blocking_time`, should gevent print a detailed
 |      report about the block?
 |
 |      The report is generated and notifications are broadcast whether
 |      or not the report is printed.
 |
 |      .. versionadded:: 25.4.1
 |
 |      This is a boolean value.
 |
 |      In the environment variable, it may be given as ``1``, ``true``,
 |      ``on`` or ``yes`` for `True`, or ``0``, ``false``, ``off``, or
 |      ``no`` for `False`.
 |
 |      The default value is `True`
 |
 |      The environment variable ``GEVENT_MONITOR_PRINT_BLOCKING_REPORTS`` can be used to control this.
 |
 |  resolver
 |      The callable that will be used to create
 |      :attr:`gevent.hub.Hub.resolver`.
 |
 |      See :doc:`dns` for more information.
 |
 |      This is an importable value. It can be given as a string naming an importable object, or a list of strings in preference order and the first successfully importable object will be used. (Separate values in the environment variable with commas.) It can also be given as the callable object itself (in code). Shorthand names for default objects are ['ares', 'thread', 'block', 'dnspython']
 |
 |      The default value is `['thread', 'dnspython', 'ares', 'block']`
 |
 |      The environment variable ``GEVENT_RESOLVER`` can be used to control this.
 |
 |  resolver_nameservers
 |      A list of strings giving the IP addresses of nameservers for the (non-system) resolver.
 |
 |      In the environment variable, these strings are separated by commas.
 |
 |      .. rubric:: Resolver Behaviour
 |
 |      * blocking
 |
 |        Ignored
 |
 |      * Threaded
 |
 |        Ignored
 |
 |      * dnspython
 |
 |        If this setting is not given, the dnspython resolver will
 |        load nameservers to use from ``/etc/resolv.conf``
 |        or the Windows registry. This setting replaces any nameservers read
 |        from those means. Note that the file and registry are still read
 |        for other settings.
 |
 |        .. caution:: dnspython does not validate the members of the list.
 |           An improper address (such as a hostname instead of IP) has
 |           undefined results, including hanging the process.
 |
 |      * ares
 |
 |        Similar to dnspython, but with more platform and compile-time
 |        options. ares validates that the members of the list are valid
 |        addresses.
 |
 |      The default value is `None`
 |
 |      The environment variable ``GEVENT_RESOLVER_NAMESERVERS`` can be used to control this.
 |
 |  resolver_timeout
 |      The total amount of time that the DNS resolver will spend making queries.
 |
 |      Only the ares and dnspython resolvers support this.
 |
 |      .. versionadded:: 1.3a2
 |
 |      The default value is `None`
 |
 |      The environment variable ``GEVENT_RESOLVER_TIMEOUT`` can be used to control this.
 |
 |  threadpool
 |      The kind of threadpool we use.
 |
 |      This is an importable value. It can be given as a string naming an importable object, or a list of strings in preference order and the first successfully importable object will be used. (Separate values in the environment variable with commas.) It can also be given as the callable object itself (in code).
 |
 |      The default value is `gevent.threadpool.ThreadPool`
 |
 |      The environment variable ``GEVENT_THREADPOOL`` can be used to control this.
 |
 |  threadpool_idle_task_timeout
 |      How long threads in the default threadpool (used for
 |      DNS by default) are allowed to be idle before exiting.
 |
 |      Use -1 for no timeout.
 |
 |      .. versionadded:: 22.08.0
 |
 |      The default value is `5.0`
 |
 |      The environment variable ``GEVENT_THREADPOOL_IDLE_TASK_TIMEOUT`` can be used to control this.
 |
 |  trace_malloc
 |      Should FFI objects track their allocation?
 |
 |      This is only useful for low-level debugging.
 |
 |      On Python 3, this environment variable is built in to the
 |      interpreter, and it may also be set with the ``-X
 |      tracemalloc`` command line argument.
 |
 |      On Python 2, gevent interprets this argument and adds extra
 |      tracking information for FFI objects.
 |
 |      The default value is `False`
 |
 |      The environment variable ``PYTHONTRACEMALLOC`` can be used to control this.
 |
 |  track_greenlet_tree
 |      Should `Greenlet` objects track their spawning tree?
 |
 |      Setting this to a false value will make spawning `Greenlet`
 |      objects and using `spawn_raw` faster, but the
 |      ``spawning_greenlet``, ``spawn_tree_locals`` and ``spawning_stack``
 |      will not be captured. Setting this to a false value can also
 |      reduce memory usage because capturing the stack captures
 |      some information about Python frames.
 |
 |      .. versionadded:: 1.3b1
 |
 |      This is a boolean value.
 |
 |      In the environment variable, it may be given as ``1``, ``true``,
 |      ``on`` or ``yes`` for `True`, or ``0``, ``false``, ``off``, or
 |      ``no`` for `False`.
 |
 |      The default value is `True`
 |
 |      The environment variable ``GEVENT_TRACK_GREENLET_TREE`` can be used to control this.
gevent.get_hub
Python Library Documentation: cython_function_or_method in module gevent._gevent_c_hub_local

get_hub()
    Return the hub for the current thread.

    If a hub does not exist in the current thread, a new one is
    created of the type returned by :func:`get_hub_class`.

    .. deprecated:: 1.3b1
       The ``*args`` and ``**kwargs`` arguments are deprecated. They were
       only used when the hub was created, and so were non-deterministic---to be
       sure they were used, *all* callers had to pass them, or they were order-dependent.
       Use ``set_hub`` instead.

    .. versionchanged:: 1.5a3
       The *args* and *kwargs* arguments are now completely ignored.

    .. versionchanged:: 23.7.0
       The long-deprecated ``args`` and ``kwargs`` parameters are no
       longer accepted.
gevent.getcurrent
Python Library Documentation: built-in function getcurrent in module greenlet._greenlet

getcurrent(...)
    getcurrent() -> greenlet

    Returns the current greenlet (i.e. the one which called this function).
gevent.getswitchinterval
Python Library Documentation: built-in function getswitchinterval in module sys

getswitchinterval()
    Return the current thread switch interval; see sys.setswitchinterval().
gevent.idle
Python Library Documentation: function idle in module gevent.hub

idle(priority=0)
    Cause the calling greenlet to wait until the event loop is idle.

    Idle is defined as having no other events of the same or higher
    *priority* pending. That is, as long as sockets, timeouts or even
    signals of the same or higher priority are being processed, the loop
    is not idle.

    .. seealso:: :func:`sleep`
gevent.iwait
Python Library Documentation: cython_function_or_method in module gevent._gevent_c_hub_primitives

iwait_on_objects(objects, timeout=None, count=None)
    iwait_on_objects(objects, timeout=None, count=None)

    Iteratively yield *objects* as they are ready, until all (or *count*) are ready
    or *timeout* expired.

    If you will only be consuming a portion of the *objects*, you should
    do so inside a ``with`` block on this object to avoid leaking resources::

        with gevent.iwait((a, b, c)) as it:
            for i in it:
                if i is a:
                    break

    :param objects: A sequence (supporting :func:`len`) containing objects
        implementing the wait protocol (rawlink() and unlink()).
    :keyword int count: If not `None`, then a number specifying the maximum number
        of objects to wait for. If ``None`` (the default), all objects
        are waited for.
    :keyword float timeout: If given, specifies a maximum number of seconds
        to wait. If the timeout expires before the desired waited-for objects
        are available, then this method returns immediately.

    .. seealso:: :func:`wait`

    .. versionchanged:: 1.1a1
       Add the *count* parameter.
    .. versionchanged:: 1.1a2
       No longer raise :exc:`LoopExit` if our caller switches greenlets
       in between items yielded by this function.
    .. versionchanged:: 1.4
       Add support to use the returned object as a context manager.
gevent.joinall
Python Library Documentation: cython_function_or_method in module gevent._gevent_cgreenlet

joinall(greenlets, timeout=None, raise_error=False, count=None)
    joinall(greenlets, timeout=None, raise_error=False, count=None)

    Wait for the ``greenlets`` to finish.

    :param greenlets: A sequence (supporting :func:`len`) of greenlets to wait for.
    :keyword float timeout: If given, the maximum number of seconds to wait.
    :keyword bool raise_error: If True, immediately raise the first exception
        encountered in any greenlet. If False (default), exceptions are
        stored in the greenlet and not raised.
    :keyword int count: If not `None`, then a number specifying the maximum number
        of greenlets to wait for. If ``None`` (the default), all greenlets
        are waited for.
    :return: A sequence of the greenlets that finished before the timeout (if any)
        expired.
gevent.kill
Python Library Documentation: function kill in module gevent.hub

kill(greenlet, exception=<class 'greenlet.GreenletExit'>)
    Kill greenlet asynchronously. The current greenlet is not unscheduled.

    .. note::

        The method :meth:`Greenlet.kill` method does the same and
        more (and the same caveats listed there apply here). However, the MAIN
        greenlet - the one that exists initially - does not have a
        ``kill()`` method, and neither do any created with :func:`spawn_raw`,
        so you have to use this function.

    .. caution:: Use care when killing greenlets. If they are not prepared for
       exceptions, this could result in corrupted state.

    .. versionchanged:: 1.1a2
        If the ``greenlet`` has a :meth:`kill <Greenlet.kill>` method, calls it. This prevents a
        greenlet from being switched to for the first time after it's been
        killed but not yet executed.
gevent.killall
Python Library Documentation: cython_function_or_method in module gevent._gevent_cgreenlet

killall(greenlets, exception=<class 'greenlet.GreenletExit'>, block=True, timeout=None)
    killall(greenlets, exception=GreenletExit, block=True, timeout=None)

    Forceably terminate all the *greenlets* by causing them to raise *exception*.

    .. caution:: Use care when killing greenlets. If they are not prepared for exceptions,
       this could result in corrupted state.

    :param greenlets: A **bounded** iterable of the non-None greenlets to terminate.
       *All* the items in this iterable must be greenlets that belong to the same hub,
       which should be the hub for this current thread. If this is a generator or iterator
       that switches greenlets, the results are undefined.
    :keyword exception: The type of exception to raise in the greenlets. By default this is
        :class:`GreenletExit`.
    :keyword bool block: If True (the default) then this function only returns when all the
        greenlets are dead; the current greenlet is unscheduled during that process.
        If greenlets ignore the initial exception raised in them,
        then they will be joined (with :func:`gevent.joinall`) and allowed to die naturally.
        If False, this function returns immediately and greenlets will raise
        the exception asynchronously.
    :keyword float timeout: A time in seconds to wait for greenlets to die. If given, it is
        only honored when ``block`` is True.
    :raise Timeout: If blocking and a timeout is given that elapses before
        all the greenlets are dead.

    .. versionchanged:: 1.1a2
        *greenlets* can be any iterable of greenlets, like an iterator or a set.
        Previously it had to be a list or tuple.
    .. versionchanged:: 1.5a3
        Any :class:`Greenlet` in the *greenlets* list that hadn't been switched to before
        calling this method will never be switched to. This makes this function
        behave like :meth:`Greenlet.kill`. This does not apply to raw greenlets.
    .. versionchanged:: 1.5a3
        Now accepts raw greenlets created by :func:`gevent.spawn_raw`.
gevent.namedtuple
Python Library Documentation: function namedtuple in module collections

namedtuple(typename, field_names, *, rename=False, defaults=None, module=None)
    Returns a new subclass of tuple with named fields.

    >>> Point = namedtuple('Point', ['x', 'y'])
    >>> Point.__doc__                   # docstring for the new class
    'Point(x, y)'
    >>> p = Point(11, y=22)             # instantiate with positional args or keywords
    >>> p[0] + p[1]                     # indexable like a plain tuple
    33
    >>> x, y = p                        # unpack like a regular tuple
    >>> x, y
    (11, 22)
    >>> p.x + p.y                       # fields also accessible by name
    33
    >>> d = p._asdict()                 # convert to a dictionary
    >>> d['x']
    11
    >>> Point(**d)                      # convert from a dictionary
    Point(x=11, y=22)
    >>> p._replace(x=100)               # _replace() is like str.replace() but targets named fields
    Point(x=100, y=22)
gevent.reinit
Python Library Documentation: function reinit in module gevent.hub

reinit(hub=None)
    reinit() -> None

    Prepare the gevent hub to run in a new (forked) process.

    This should be called *immediately* after :func:`os.fork` in the
    child process. This is done automatically by
    :func:`gevent.os.fork` or if the :mod:`os` module has been
    monkey-patched. If this function is not called in a forked
    process, symptoms may include hanging of functions like
    :func:`socket.getaddrinfo`, and the hub's threadpool is unlikely
    to work.

    .. note:: Registered fork watchers may or may not run before
       this function (and thus ``gevent.os.fork``) return. If they have
       not run, they will run "soon", after an iteration of the event loop.
       You can force this by inserting a few small (but non-zero) calls to :func:`sleep`
       after fork returns. (As of gevent 1.1 and before, fork watchers will
       not have run, but this may change in the future.)

    .. note:: This function may be removed in a future major release
       if the fork process can be more smoothly managed.

    .. warning:: See remarks in :func:`gevent.os.fork` about greenlets
       and event loop watchers in the child process.
gevent.setswitchinterval
Python Library Documentation: built-in function setswitchinterval in module sys

setswitchinterval(interval, /)
    Set the ideal thread switching delay inside the Python interpreter.

    The actual frequency of switching threads can be lower if the
    interpreter executes long sequences of uninterruptible code
    (this is implementation-specific and workload-dependent).

    The parameter must represent the desired switching delay in seconds
    A typical value is 0.005 (5 milliseconds).
gevent.signal_handler
Python Library Documentation: class signal in module gevent.hub

class signal(builtins.object)
 |  signal(signalnum, handler, *args, **kwargs)
 |
 |  signal_handler(signalnum, handler, *args, **kwargs) -> object
 |
 |  Call the *handler* with the *args* and *kwargs* when the process
 |  receives the signal *signalnum*.
 |
 |  The *handler* will be run in a new greenlet when the signal is
 |  delivered.
 |
 |  This returns an object with the useful method ``cancel``, which,
 |  when called, will prevent future deliveries of *signalnum* from
 |  calling *handler*. It's best to keep the returned object alive
 |  until you call ``cancel``.
 |
 |  .. note::
 |
 |      This may not operate correctly with ``SIGCHLD`` if libev child
 |      watchers are used (as they are by default with
 |      `gevent.os.fork`). See :mod:`gevent.signal` for a more
 |      general purpose solution.
 |
 |  .. versionchanged:: 1.2a1
 |
 |      The ``handler`` argument is required to
 |      be callable at construction time.
 |
 |  .. versionchanged:: 20.5.1
 |     The ``cancel`` method now properly cleans up all native resources,
 |     and drops references to all the arguments of this function.
 |
 |  Methods defined here:
 |
 |  __init__(self, signalnum, handler, *args, **kwargs)
 |      Initialize self.  See help(type(self)) for accurate signature.
 |
 |  cancel(self)
 |
 |  handle(self)
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ref
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes defined here:
 |
 |  greenlet_class = None
gevent.sleep
Python Library Documentation: function sleep in module gevent.hub

sleep(seconds=0, ref=True)
    Put the current greenlet to sleep for at least *seconds*.

    *seconds* may be specified as an integer, or a float if fractional
    seconds are desired.

    .. tip:: In the current implementation, a value of 0 (the default)
       means to yield execution to any other runnable greenlets, but
       this greenlet may be scheduled again before the event loop
       cycles (in an extreme case, a greenlet that repeatedly sleeps
       with 0 can prevent greenlets that are ready to do I/O from
       being scheduled for some (small) period of time); a value greater than
       0, on the other hand, will delay running this greenlet until
       the next iteration of the loop.

    If *ref* is False, the greenlet running ``sleep()`` will not prevent :func:`gevent.wait`
    from exiting.

    .. versionchanged:: 1.3a1
       Sleeping with a value of 0 will now be bounded to approximately block the
       loop for no longer than :func:`gevent.getswitchinterval`.

    .. seealso:: :func:`idle`
gevent.spawn
Python Library Documentation: method spawn in module gevent._gevent_cgreenlet

spawn(*args, **kwargs) class method of gevent._gevent_cgreenlet.Greenlet
    Greenlet.spawn(cls, *args, **kwargs)

    spawn(function, *args, **kwargs) -> Greenlet

    Create a new :class:`Greenlet` object and schedule it to run ``function(*args, **kwargs)``.
    This can be used as ``gevent.spawn`` or ``Greenlet.spawn``.

    The arguments are passed to :meth:`Greenlet.__init__`.

    .. versionchanged:: 1.1b1
        If a *function* is given that is not callable, immediately raise a :exc:`TypeError`
        instead of spawning a greenlet that will raise an uncaught TypeError.
gevent.spawn_later
Python Library Documentation: method spawn_later in module gevent._gevent_cgreenlet

spawn_later(seconds, *args, **kwargs) class method of gevent._gevent_cgreenlet.Greenlet
    Greenlet.spawn_later(cls, seconds, *args, **kwargs)

    spawn_later(seconds, function, *args, **kwargs) -> Greenlet

    Create and return a new `Greenlet` object scheduled to run ``function(*args, **kwargs)``
    in a future loop iteration *seconds* later. This can be used as ``Greenlet.spawn_later``
    or ``gevent.spawn_later``.

    The arguments are passed to :meth:`Greenlet.__init__`.

    .. versionchanged:: 1.1b1
       If an argument that's meant to be a function (the first argument in *args*, or the ``run`` keyword )
       is given to this classmethod (and not a classmethod of a subclass),
       it is verified to be callable. Previously, the spawned greenlet would have failed
       when it started running.
gevent.spawn_raw
Python Library Documentation: function spawn_raw in module gevent.hub

spawn_raw(function, *args, **kwargs)
    Create a new :class:`greenlet.greenlet` object and schedule it to
    run ``function(*args, **kwargs)``.

    This returns a raw :class:`~greenlet.greenlet` which does not have all the useful
    methods that :class:`gevent.Greenlet` has. Typically, applications
    should prefer :func:`~gevent.spawn`, but this method may
    occasionally be useful as an optimization if there are many
    greenlets involved.

    .. versionchanged:: 1.1a3
        Verify that ``function`` is callable, raising a TypeError if not. Previously,
        the spawned greenlet would have failed the first time it was switched to.

    .. versionchanged:: 1.1b1
       If *function* is not callable, immediately raise a :exc:`TypeError`
       instead of spawning a greenlet that will raise an uncaught TypeError.

    .. versionchanged:: 1.1rc2
        Accept keyword arguments for ``function`` as previously (incorrectly)
        documented. Note that this may incur an additional expense.

    .. versionchanged:: 1.3a2
       Populate the ``spawning_greenlet`` and ``spawn_tree_locals``
       attributes of the returned greenlet.

    .. versionchanged:: 1.3b1
       *Only* populate ``spawning_greenlet`` and ``spawn_tree_locals``
       if ``GEVENT_TRACK_GREENLET_TREE`` is enabled (the default). If not enabled,
       those attributes will not be set.

    .. versionchanged:: 1.5a3
       The returned greenlet always has a *loop* attribute matching the
       current hub's loop. This helps it work better with more gevent APIs.
gevent.version_info
Python Library Documentation: version_info in module gevent object

class version_info(builtins.tuple)
 |  version_info(major, minor, micro, releaselevel, serial)
 |
 |  version_info(major, minor, micro, releaselevel, serial)
 |
 |  Method resolution order:
 |      version_info
 |      builtins.tuple
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __getnewargs__(self) from collections.version_info
 |      Return self as a plain tuple.  Used by copy and pickle.
 |
 |  __repr__(self) from collections.version_info
 |      Return a nicely formatted representation string
 |
 |  _asdict(self) from collections.version_info
 |      Return a new dict which maps field names to their values.
 |
 |  _replace(self, /, **kwds) from collections.version_info
 |      Return a new version_info object replacing specified fields with new values
 |
 |  ----------------------------------------------------------------------
 |  Class methods defined here:
 |
 |  _make(iterable) from collections.version_info
 |      Make a new version_info object from a sequence or iterable
 |
 |  ----------------------------------------------------------------------
 |  Static methods defined here:
 |
 |  __new__(_cls, major, minor, micro, releaselevel, serial) from namedtuple_version_info.version_info
 |      Create new instance of version_info(major, minor, micro, releaselevel, serial)
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  major
 |      Alias for field number 0
 |
 |  minor
 |      Alias for field number 1
 |
 |  micro
 |      Alias for field number 2
 |
 |  releaselevel
 |      Alias for field number 3
 |
 |  serial
 |      Alias for field number 4
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes defined here:
 |
 |  __match_args__ = ('major', 'minor', 'micro', 'releaselevel', 'serial')
 |
 |  _field_defaults = {}
 |
 |  _fields = ('major', 'minor', 'micro', 'releaselevel', 'serial')
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from builtins.tuple:
 |
 |  __add__(self, value, /)
 |      Return self+value.
 |
 |  __contains__(self, key, /)
 |      Return bool(key in self).
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __getitem__(self, key, /)
 |      Return self[key].
 |
 |  __gt__(self, value, /)
 |      Return self>value.
 |
 |  __hash__(self, /)
 |      Return hash(self).
 |
 |  __iter__(self, /)
 |      Implement iter(self).
 |
 |  __le__(self, value, /)
 |      Return self<=value.
 |
 |  __len__(self, /)
 |      Return len(self).
 |
 |  __lt__(self, value, /)
 |      Return self<value.
 |
 |  __mul__(self, value, /)
 |      Return self*value.
 |
 |  __ne__(self, value, /)
 |      Return self!=value.
 |
 |  __rmul__(self, value, /)
 |      Return value*self.
 |
 |  count(self, value, /)
 |      Return number of occurrences of value.
 |
 |  index(self, value, start=0, stop=9223372036854775807, /)
 |      Return first index of value.
 |
 |      Raises ValueError if the value is not present.
 |
 |  ----------------------------------------------------------------------
 |  Class methods inherited from builtins.tuple:
 |
 |  __class_getitem__(...)
 |      See PEP 585
gevent.wait
Python Library Documentation: cython_function_or_method in module gevent._gevent_c_hub_primitives

wait_on_objects(objects=None, timeout=None, count=None)
    wait_on_objects(objects=None, timeout=None, count=None)

    Wait for *objects* to become ready or for event loop to finish.

    If *objects* is provided, it must be a list containing objects
    implementing the wait protocol (rawlink() and unlink() methods):

    - :class:`gevent.Greenlet` instance
    - :class:`gevent.event.Event` instance
    - :class:`gevent.lock.Semaphore` instance
    - :class:`gevent.subprocess.Popen` instance

    If *objects* is ``None`` (the default), ``wait()`` blocks until
    the current event loop has nothing to do (or until *timeout* passes):

    - all greenlets have finished
    - all servers were stopped
    - all event loop watchers were stopped.

    If *count* is ``None`` (the default), wait for all *objects*
    to become ready.

    If *count* is a number, wait for (up to) *count* objects to become
    ready. (For example, if count is ``1`` then the function exits
    when any object in the list is ready).

    If *timeout* is provided, it specifies the maximum number of
    seconds ``wait()`` will block.

    Returns the list of ready objects, in the order in which they were
    ready.

    .. seealso:: :func:`iwait`
gevent.with_timeout
Python Library Documentation: function with_timeout in module gevent.timeout

with_timeout(seconds, function, *args, **kwds)
    Wrap a call to *function* with a timeout; if the called
    function fails to return before the timeout, cancel it and return a
    flag value, provided by *timeout_value* keyword argument.

    If timeout expires but *timeout_value* is not provided, raise :class:`Timeout`.

    Keyword argument *timeout_value* is not passed to *function*.