gevent.thread – Implementation of the standard thread module that spawns greenlets

Implementation of the standard thread module that spawns greenlets.

Note

This module is a helper for gevent.monkey and is not intended to be used directly. For spawning greenlets in your applications, prefer higher level constructs like gevent.Greenlet class or gevent.spawn().

exception error

Bases: exceptions.Exception

allocate_lock

alias of gevent.thread.LockType

class LockType(*args, **kwargs)[source]

Bases: gevent.lock.BoundedSemaphore

acquire(blocking=True, timeout=None) → bool[source]

Acquire the semaphore.

Note

If this semaphore was initialized with a value of 0, this method will block forever (unless a timeout is given or blocking is set to false).

Parameters:
  • blocking (bool) – If True (the default), this function will block until the semaphore is acquired.
  • timeout (float) – If given, and blocking is true, specifies the maximum amount of seconds this method will block.
Returns:

A bool indicating whether the semaphore was acquired. If blocking is True and timeout is None (the default), then (so long as this semaphore was initialized with a size greater than 0) this will always return True. If a timeout was given, and it expired before the semaphore was acquired, False will be returned. (Note that this can still raise a Timeout exception, if some other caller had already started a timer.)

Next page: gevent.threading – Implementation of the standard threading using greenlets