Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.rst

@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.

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 del ete:

client = SuperClientWrapper()
client.something()
del client.nonthreadsafe_client
client.something()

Module works on Python == 2.7 and Python ~= 3.4.

Installation

pip install tls-property

License

Public Domain: CC0 1.0 Universal.

About

Thread-local storage property

Topics

Resources

License

Packages

No packages published

Languages

You can’t perform that action at this time.