def __init__(self,
num_threads,
sleep=InterruptibleSleep):
"""Constructor for ThreadGate instances.
Args:
num_threads: The total number of threads using this gate.
sleep: Used for dependency injection.
"""
self.__enabled_count = 1
self.__lock = threading.Lock()
self.__thread_semaphore = threading.Semaphore(self.__enabled_count)
self.__num_threads = num_threads
self.__backoff_time = 0
self.__sleep = sleep
评论列表
文章目录