⚡⚡⚡ Fast, Lightweight, Pluggable, TLS interception capable proxy server focused on Network monitoring, controls & Application development, testing, debugging.
2013-present by Abhinav Singh and contributors.
BSD, see LICENSE for more details.
- class proxy.common.backports.NonBlockingQueue#
Simple, unbounded, non-blocking FIFO queue.
Supports only a single consumer.
NOTE: This is available in Python since 3.7 as SimpleQueue. Here because proxy.py still supports 3.6
- get() Any #
Remove and return an item from the queue.
- class proxy.common.backports.cached_property(ttl: float = 0)#
Decorator for read-only properties evaluated only once within TTL period. It can be used to create a cached property like this:
import random # the class containing the property must be a new-style class class MyClass: # create property whose value is cached for ten minutes @cached_property(ttl=600) def randint(self): # will only be evaluated every 10 min. at maximum. return random.randint(0, 100)
The value is cached in the ‘_cached_properties’ attribute of the object instance that has the property getter method wrapped by this decorator. The ‘_cached_properties’ attribute value is a dictionary which has a key for every property of the object which is wrapped by this decorator. Each entry in the cache is created only when the property is accessed for the first time and is a two-element tuple with the last computed property value and the last time it was updated in seconds since the epoch.
The default time-to-live (TTL) is 0 seconds i.e. cached value will never expire.
- To expire a cached property value manually just do::
del instance._cached_properties[<property name>]
Adopted from https://wiki.python.org/moin/PythonDecoratorLibrary#Cached_Properties © 2011 Christopher Arndt, MIT License.
NOTE: We need this function only because Python in-built are only available for 3.8+. Hence, we must get rid of this function once proxy.py no longer support version older than 3.8.