This document describes the current stable version of Celery (4.0). For development docs, go here.
celery.utils.threads
¶
Threading primitives and utilities.
-
celery.utils.threads.
LocalStack
¶ alias of
_LocalStack
-
class
celery.utils.threads.
LocalManager
(locals=None, ident_func=None)[source]¶ Local objects cannot manage themselves.
For that you need a local manager. You can pass a local manager multiple locals or add them later by appending them to
manager.locals
. Every time the manager cleans up, it will clean up all the data left in the locals for this context.The
ident_func
parameter can be added to override the default ident function for the wrapped locals.
-
celery.utils.threads.
get_ident
() → integer¶ Return a non-zero integer that uniquely identifies the current thread amongst other threads that exist simultaneously. This may be used to identify per-thread resources. Even though on some platforms threads identities may appear to be allocated consecutive numbers starting at 1, this behavior should not be relied upon, and the number should be seen purely as a magic cookie. A thread’s identity may be reused for another thread after it exits.