Skip to main content

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

Metadata

Release files for tls-property 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tls-property 1.1.0
File Size Uploaded
tls-property-1.1.0.tar.gz 2.3 kB Details

Release files / tls-property-1.1.0.tar.gz

Download URL tls-property-1.1.0.tar.gz
Size 2.3 kB
Tags Source
SHA-256 checksum
How to use checksums
cddf1152620e7c09307de5348a10d945070f0521183738a1fabaff17ad56343d
BLAKE2b-256 checksum
How to use checksums
d983441bac852a9fb9d6d6c7af42a1571052668d6c6a9945fe21ce7e0060d6ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

Release history Release notifications | RSS feed

This release

1.1.0 This release

1 release file

1.0.1

1 release file

1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page