proxywatchd: add __slots__ to hot objects for memory reduction
This commit is contained in:
@@ -239,11 +239,20 @@ class ThreadScaler(object):
|
|||||||
return 'threads=%d queue=%d target_per_thread=%d' % (
|
return 'threads=%d queue=%d target_per_thread=%d' % (
|
||||||
current_threads, queue_size, self.target_queue_per_thread)
|
current_threads, queue_size, self.target_queue_per_thread)
|
||||||
|
|
||||||
class ProxyTestState():
|
class ProxyTestState(object):
|
||||||
"""Thread-safe state for a proxy being tested.
|
"""Thread-safe state for a proxy being tested.
|
||||||
|
|
||||||
Holds test results and evaluates final pass/fail status.
|
Holds test results and evaluates final pass/fail status.
|
||||||
"""
|
"""
|
||||||
|
__slots__ = (
|
||||||
|
'ip', 'port', 'proxy', 'auth', 'proto', 'failcount', 'checktime',
|
||||||
|
'success_count', 'total_duration', 'country', 'mitm', 'consecutive_success',
|
||||||
|
'asn', 'isoldies', 'completion_queue', 'lock', 'results', 'completed',
|
||||||
|
'evaluated', 'last_latency_ms', 'exit_ip', 'reveals_headers',
|
||||||
|
'last_fail_category', 'original_failcount', 'had_ssl_test', 'ssl_success',
|
||||||
|
'cert_error'
|
||||||
|
)
|
||||||
|
|
||||||
def __init__(self, ip, port, proto, failcount, success_count, total_duration,
|
def __init__(self, ip, port, proto, failcount, success_count, total_duration,
|
||||||
country, mitm, consecutive_success, asn=None, oldies=False,
|
country, mitm, consecutive_success, asn=None, oldies=False,
|
||||||
completion_queue=None, proxy_full=None):
|
completion_queue=None, proxy_full=None):
|
||||||
@@ -433,12 +442,14 @@ class ProxyTestState():
|
|||||||
return (False, fail_category)
|
return (False, fail_category)
|
||||||
|
|
||||||
|
|
||||||
class TargetTestJob():
|
class TargetTestJob(object):
|
||||||
"""Job to test a single proxy against a single target.
|
"""Job to test a single proxy against a single target.
|
||||||
|
|
||||||
Multiple TargetTestJob instances share the same ProxyTestState,
|
Multiple TargetTestJob instances share the same ProxyTestState,
|
||||||
allowing tests to be interleaved with other proxies in the queue.
|
allowing tests to be interleaved with other proxies in the queue.
|
||||||
"""
|
"""
|
||||||
|
__slots__ = ('proxy_state', 'target_srv', 'checktype', 'worker_id')
|
||||||
|
|
||||||
def __init__(self, proxy_state, target_srv, checktype, worker_id=None):
|
def __init__(self, proxy_state, target_srv, checktype, worker_id=None):
|
||||||
self.proxy_state = proxy_state
|
self.proxy_state = proxy_state
|
||||||
self.target_srv = target_srv
|
self.target_srv = target_srv
|
||||||
|
|||||||
Reference in New Issue
Block a user