eventlet.hubs package
*********************


Submodules
==========


eventlet.hubs.asyncio module
============================

Asyncio-based hub, originally implemented by Miguel Grinberg.

class eventlet.hubs.asyncio.Hub

   Bases: "BaseHub"

   An Eventlet hub implementation on top of an asyncio event loop.

   add(evtype, fileno, cb, tb, mark_as_closed)

      Add a file descriptor of given event type to the "Hub".  See the
      superclass for details.

      Typically not called directly by users.

   add_timer(timer)

      Register a "Timer".

      Typically not called directly by users.

   remove(listener)

      Remove a listener from the "Hub".  See the superclass for
      details.

      Typically not called directly by users.

   remove_descriptor(fileno)

      Remove a file descriptor from the "asyncio" loop.

      Typically not called directly by users.

   run(*a, **kw)

      Start the "Hub" running. See the superclass for details.

eventlet.hubs.asyncio.is_available()

   Indicate whether this hub is available, since some hubs are
   platform-specific.

   Python always has asyncio, so this is always "True".


eventlet.hubs.epolls module
===========================

class eventlet.hubs.epolls.Hub(clock=None)

   Bases: "Hub"

   add(evtype, fileno, cb, tb, mac)

      Signals an intent to or write a particular file descriptor.

      The *evtype* argument is either the constant READ or WRITE.

      The *fileno* argument is the file number of the file of
      interest.

      The *cb* argument is the callback which will be called when the
      file is ready for reading/writing.

      The *tb* argument is the throwback used to signal (into the
      greenlet) that the file was closed.

      The *mark_as_closed* is used in the context of the event hub to
      prepare a Python object as being closed, pre-empting further
      close operations from accidentally shutting down the wrong OS
      thread.

   do_poll(seconds)

eventlet.hubs.epolls.is_available()


eventlet.hubs.hub module
========================

class eventlet.hubs.hub.BaseHub(clock=None)

   Bases: "object"

   Base hub class for easing the implementation of subclasses that are
   specific to a particular underlying event architecture.

   READ = 'read'

   SYSTEM_EXCEPTIONS = (<class 'KeyboardInterrupt'>, <class 'SystemExit'>)

   WRITE = 'write'

   abort(wait=False)

      Stop the runloop. If run is executing, it will exit after
      completing the next runloop iteration.

      Set *wait* to True to cause abort to switch to the hub
      immediately and wait until it's finished processing.  Waiting
      for the hub will only work from the main greenthread; all other
      greenthreads will become unreachable.

   add(evtype, fileno, cb, tb, mark_as_closed)

      Signals an intent to or write a particular file descriptor.

      The *evtype* argument is either the constant READ or WRITE.

      The *fileno* argument is the file number of the file of
      interest.

      The *cb* argument is the callback which will be called when the
      file is ready for reading/writing.

      The *tb* argument is the throwback used to signal (into the
      greenlet) that the file was closed.

      The *mark_as_closed* is used in the context of the event hub to
      prepare a Python object as being closed, pre-empting further
      close operations from accidentally shutting down the wrong OS
      thread.

   add_timer(timer)

   block_detect_post()

   block_detect_pre()

   close_one()

      Triggered from the main run loop. If a listener's underlying FD
      was closed somehow, throw an exception back to the trampoline,
      which should be able to manage it appropriately.

   default_sleep()

   ensure_greenlet()

   fire_timers(when)

   get_readers()

   get_timers_count()

   get_writers()

   mark_as_reopened(fileno)

      If a file descriptor is returned by the OS as the result of some
      open call (or equivalent), that signals that it might be being
      recycled.

      Catch the case where the fd was previously in use.

   notify_close(fileno)

      We might want to do something when a fileno is closed. However,
      currently it suffices to obsolete listeners only when we detect
      an old fileno being recycled, on open.

   prepare_timers()

   remove(listener)

   remove_descriptor(fileno)

      Completely remove all listeners for this fileno.  For internal
      use only.

   run(*a, **kw)

      Run the runloop until abort is called.

   schedule_call_global(seconds, cb, *args, **kw)

      Schedule a callable to be called after 'seconds' seconds have
      elapsed. The timer will NOT be canceled if the current greenlet
      has exited before the timer fires.

         seconds: The number of seconds to wait. cb: The callable to
         call after the given time. >>*<<args: Arguments to pass to
         the callable when called. >>**<<kw: Keyword arguments to pass
         to the callable when called.

   schedule_call_local(seconds, cb, *args, **kw)

      Schedule a callable to be called after 'seconds' seconds have
      elapsed. Cancel the timer if greenlet has exited.

         seconds: The number of seconds to wait. cb: The callable to
         call after the given time. >>*<<args: Arguments to pass to
         the callable when called. >>**<<kw: Keyword arguments to pass
         to the callable when called.

   set_debug_listeners(value)

   set_timer_exceptions(value)

   sleep_until()

   squelch_exception(fileno, exc_info)

   squelch_generic_exception(exc_info)

   squelch_timer_exception(timer, exc_info)

   switch()

   timer_canceled(timer)

   wait(seconds=None)

class eventlet.hubs.hub.DebugListener(evtype, fileno, cb, tb, mark_as_closed)

   Bases: "FdListener"

class eventlet.hubs.hub.FdListener(evtype, fileno, cb, tb, mark_as_closed)

   Bases: "object"

   defang()

eventlet.hubs.hub.alarm_handler(signum, frame)

eventlet.hubs.hub.alarm_itimer(seconds)

eventlet.hubs.hub.arm_alarm(seconds)

eventlet.hubs.hub.closed_callback(fileno)

   Used to de-fang a callback that may be triggered by a loop in
   BaseHub.wait


eventlet.hubs.kqueue module
===========================

class eventlet.hubs.kqueue.Hub(clock=None)

   Bases: "BaseHub"

   MAX_EVENTS = 100

   add(evtype, fileno, cb, tb, mac)

      Signals an intent to or write a particular file descriptor.

      The *evtype* argument is either the constant READ or WRITE.

      The *fileno* argument is the file number of the file of
      interest.

      The *cb* argument is the callback which will be called when the
      file is ready for reading/writing.

      The *tb* argument is the throwback used to signal (into the
      greenlet) that the file was closed.

      The *mark_as_closed* is used in the context of the event hub to
      prepare a Python object as being closed, pre-empting further
      close operations from accidentally shutting down the wrong OS
      thread.

   remove(listener)

   remove_descriptor(fileno)

      Completely remove all listeners for this fileno.  For internal
      use only.

   wait(seconds=None)

eventlet.hubs.kqueue.is_available()


eventlet.hubs.poll module
=========================

class eventlet.hubs.poll.Hub(clock=None)

   Bases: "BaseHub"

   add(evtype, fileno, cb, tb, mac)

      Signals an intent to or write a particular file descriptor.

      The *evtype* argument is either the constant READ or WRITE.

      The *fileno* argument is the file number of the file of
      interest.

      The *cb* argument is the callback which will be called when the
      file is ready for reading/writing.

      The *tb* argument is the throwback used to signal (into the
      greenlet) that the file was closed.

      The *mark_as_closed* is used in the context of the event hub to
      prepare a Python object as being closed, pre-empting further
      close operations from accidentally shutting down the wrong OS
      thread.

   do_poll(seconds)

   register(fileno, new=False)

   remove(listener)

   remove_descriptor(fileno)

      Completely remove all listeners for this fileno.  For internal
      use only.

   wait(seconds=None)

eventlet.hubs.poll.is_available()


eventlet.hubs.pyevent module
============================


eventlet.hubs.selects module
============================

class eventlet.hubs.selects.Hub(clock=None)

   Bases: "BaseHub"

   wait(seconds=None)

eventlet.hubs.selects.is_available()


eventlet.hubs.timer module
==========================

class eventlet.hubs.timer.LocalTimer(*args, **kwargs)

   Bases: "Timer"

   cancel()

      Prevent this timer from being called. If the timer has already
      been called or canceled, has no effect.

   property pending

class eventlet.hubs.timer.Timer(seconds, cb, *args, **kw)

   Bases: "object"

   cancel()

      Prevent this timer from being called. If the timer has already
      been called or canceled, has no effect.

   copy()

   property pending

   schedule()

      Schedule this timer to run in the current runloop.


Module contents
===============

eventlet.hubs.get_default_hub()

   Select the default hub implementation based on what multiplexing
   libraries are installed.  The order that the hubs are tried is:

   * epoll

   * kqueue

   * poll

   * select

   Note:

     >>|internal|<<

eventlet.hubs.get_hub()

   Get the current event hub singleton object.

   Note:

     >>|internal|<<

eventlet.hubs.trampoline(fd, read=None, write=None, timeout=None, timeout_exc=<class 'eventlet.timeout.Timeout'>, mark_as_closed=None)

   Suspend the current coroutine until the given socket object or file
   descriptor is ready to *read*, ready to *write*, or the specified
   *timeout* elapses, depending on arguments specified.

   To wait for *fd* to be ready to read, pass *read* "=True"; ready to
   write, pass *write* "=True". To specify a timeout, pass the
   *timeout* argument in seconds.

   If the specified *timeout* elapses before the socket is ready to
   read or write, *timeout_exc* will be raised instead of
   "trampoline()" returning normally.

   Note:

     >>|internal|<<

eventlet.hubs.use_hub(mod=None)

   Use the module *mod*, containing a class called Hub, as the event
   hub. Usually not required; the default hub is usually fine.

   *mod* can be an actual hub class, a module, a string, or None.

   If *mod* is a class, use it directly. If *mod* is a module, use
   *module.Hub* class If *mod* is a string and contains either '.' or
   ':' then *use_hub* uses 'package.subpackage.module:Class'
   convention, otherwise imports *eventlet.hubs.mod*. If *mod* is
   None, *use_hub* uses the default hub.

   Only call use_hub during application initialization, because it
   resets the hub's state and any existing timers or listeners will
   never be resumed.

   These two threadlocal attributes are not part of Eventlet public
   API: - *threadlocal.Hub* (capital H) is hub constructor, used when
   no hub is currently active - *threadlocal.hub* (lowercase h) is
   active hub instance
