Skip to main content

A @decorator for caching properties in classes in the thread-local storage.

Project description

@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 _client(self) -> SuperNonThreadsafeClient:
        return SuperNonThreadsafeClient()

Module works on Python 2.7 and Python 3.4+.

Installation

pip install tls-property

License

Module is released under Public Domain as described in CC0 1.0 Universal document.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tls-property-1.0.tar.gz (3.0 kB view details)

Uploaded Source

File details

Details for the file tls-property-1.0.tar.gz.

File metadata

  • Download URL: tls-property-1.0.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/40.7.3 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.7.2

File hashes

Hashes for tls-property-1.0.tar.gz
Algorithm Hash digest
SHA256 7d5136b0e33556bf61281a1097cdaeab70c09677c5f3ebc3b5d089aafe35dc40
MD5 49626ec38008471f712baeaa334ddda5
BLAKE2b-256 f2f985485ee2932b5729ead22030979d9185bd44300f520527e2f4666ecb5651

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page