sider.threadlocal — Thread locals¶
This module provides a small thread/greenlet local object.
Why we don’t simply use the built-in
is there’s the case of using
greenlet, the non-standard
but de facto standard coroutine module for Python, in real world.
(For example, widely used networking libraries like
eventlet heavily use
LocalDict which this module offers isn’t aware of only
threads but including greenlets.
This module is inspired by
werkzeug.local module but
only things we actually need are left.
Gets the object that can identify of the current thread/greenlet. It can return an object that can be used as dictionary keys.
Returns: a something that can identify of the current thread or greenlet
Under the hood it is an alias of
greenlet.getcurrent()function if it is present. Or it will be aliased to
dummy_thread.get_ident()that both are a part of standard if
greenletmodule is not present.
However that’s all only an implementation detail and so it may changed in the future. Client codes that use
sider.threadlocal.get_ident()have to be written on only assumptions that it guarantees: it returns an object that identify of the current thread/greenlet and be used as dictionary keys.