cyme.branch.thread

cyme.branch.thread

  • Utilities for working with greenlets.
exception cyme.branch.thread.AlreadyStartedError

Raised if trying to start a thread instance that is already started.

class cyme.branch.thread.gThread
AlreadyStarted

alias of AlreadyStartedError

exception Timeout(seconds=None, exception=None)

Raises exception in the current greenthread after timeout seconds.

When exception is omitted or None, the Timeout instance itself is raised. If seconds is None, the timer is not scheduled, and is only useful if you’re planning to raise it directly.

Timeout objects are context managers, and so can be used in with statements. When used in a with statement, if exception is False, the timeout is still raised, but the context manager suppresses it, so the code outside the with-block won’t see it.

cancel()

If the timeout is pending, cancel it. If not using Timeouts in with statements, always call cancel() in a finally after the block of code that is getting timed out. If not canceled, the timeout will be raised later on, in some unexpected section of the application.

pending

True if the timeout is scheduled to be raised.

start()

Schedule the timeout. This is called on construction, so it should not be called explicitly, unless the timer has been canceled.

gThread.after()

Call after the thread has shut down.

gThread.before()

Called at the beginning of start().

gThread.extra_shutdown_steps = 0
gThread.extra_startup_steps = 0
gThread.g = None

Greenlet instance of the thread, set when the thread is started.

gThread.join(timeout=None)

Wait until the thread exits.

Parameters:timeout – Timeout in seconds (int/float).
Raises eventlet.Timeout:
 if the thread can’t be joined before the provided timeout.
gThread.joinable = True

Set this to False if it is not possible to join the thread.

gThread.kill()

Kill the green thread.

gThread.logger_name
gThread.name = None

Name of the thread, used in logs and such.

gThread.ping(timeout=None)
gThread.respond_to_ping()
gThread.run()
gThread.should_stop = False

Set when the thread is requested to stop.

gThread.spawn(fun, *args, **kwargs)
gThread.start()

Spawn green thread, and returns GreenThread instance.

gThread.start_periodic_timer(interval, fun, *args, **kwargs)

Apply function every interval seconds.

Parameters:
  • interval – Interval in seconds (int/float).
  • fun – The function to apply.
  • *args – Additional arguments to pass.
  • **kwargs – Additional keyword arguments to pass.
Returns:

entry object, with cancel and kill methods.

gThread.stop(join=True, timeout=1e+100)

Shutdown the thread.

This will also cancel+kill any periodic timers registered by the thread.

Parameters:
  • join – Given that the thread is joinable, if true will also wait until the thread exits (by calling join()).
  • timeout – Timeout for join (default is 1e+100).

Previous topic

cyme.branch.metrics

Next topic

cyme.branch.intsup

This Page