https://github.com/leenr/tls-property
Thread-local storage property
https://github.com/leenr/tls-property
python python-libary thread-local-storage
Last synced: 10 months ago
JSON representation
Thread-local storage property
- Host: GitHub
- URL: https://github.com/leenr/tls-property
- Owner: leenr
- License: cc0-1.0
- Created: 2019-02-05T10:45:28.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-08-05T13:18:50.000Z (almost 7 years ago)
- Last Synced: 2024-11-30T22:46:27.310Z (over 1 year ago)
- Topics: python, python-libary, thread-local-storage
- Language: Python
- Size: 19.5 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
=============
@tls_property
=============
`@tls_property` is a super-tiny library that will help you write
thread-safe classes.
It's acting like a `@cached_property `_,
but value will be cached only for current thread.
Garbage collecting is respected, `@tls_property` won't mess up with it.
.. code-block:: python
from some_library import NonThreadsafeSuperClient
from tls_property import tls_property
class SuperClientWrapper:
@tls_property
def nonthreadsafe_client(self) -> NonThreadsafeSuperClient:
return NonThreadsafeSuperClient()
Also, value reset supported via @tls_property :code:`del` ete:
.. code-block:: python
client = SuperClientWrapper()
client.something()
del client.nonthreadsafe_client
client.something()
..
Module works on Python == 2.7 and Python ~= 3.4.
Installation
------------
.. code-block:: bash
pip install tls-property
..
License
-------
Public Domain: `CC0 1.0 Universal `_.