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) -> NonThreadsafeSuperClient:
        return NonThreadsafeSuperClient()

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

Installation

pip install tls-property

License

Public Domain: CC0 1.0 Universal.

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.1.tar.gz (2.1 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: tls-property-1.0.1.tar.gz
  • Upload date:
  • Size: 2.1 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for tls-property-1.0.1.tar.gz
Algorithm Hash digest
SHA256 4a4f266384f33da1b1bbd2c74e637cf6fff78d06ded5a138738c1833fff0e54a
MD5 8af98663633a4e42c20d188c612bc583
BLAKE2b-256 635ec75be2a2105402a9bd4e024739ec8b5cb8dca43bfc11db74e0b38bc43e9a

See more details on using hashes here.

Supported by

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