Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __len__ (self):
with self._lock:
return await_fifo.__len__ (self)
def __getitem__(self, index):
with self._lock:
return await_fifo.__getitem__ (self, index)
def __init__ (self):
await_fifo.__init__ (self)
self._lock = threading.Lock ()
def insert (self, index, item):
with self._lock:
await_fifo.insert (self, index, item)
def __setitem__(self, index, item):
with self._lock:
await_fifo.__setitem__ (self, index, item)
from ...athreads.fifo import await_fifo, await_ts_fifo
class http2_producer_fifo (await_fifo):
# asyncore await_fifo replacement
# for resorting, removeing by http2 priority, cacnel and reset features
# also can handle producers has 'ready' method
# this class can be used only at single thread environment
def remove (self, stream_id):
if self.l:
for i in range (len (self.l)):
try:
producer_stream_id = self.l [0].stream_id
except AttributeError:
pass
else:
if producer_stream_id == stream_id:
self.l.popleft ()
self.l.rotate (1)
logger = logger_f.screen_logger ()
_logger = logger
if qrandom:
_que = queue.RandomQueue ()
else:
_que = queue.Queue ()
_allow_redirects = allow_redirects
_force_h1 = request_handler.RequestHandler.FORCE_HTTP_11 = force_http1
if not use_pool:
asynconnect.AsynConnect.keep_connect = use_pool
asynconnect.AsynSSLConnect.keep_connect = use_pool
if not _force_h1:
asynconnect.AsynConnect.fifo_class = await_fifo
asynconnect.AsynSSLConnect.fifo_class = await_fifo
http2.MAX_HTTP2_CONCURRENT_STREAMS = http2_constreams
_workers = workers
_concurrent = workers
if not force_http1:
_concurrent = workers * http2_constreams
elif http2_constreams:
pass
#_logger ("parameter http2_constreams is ignored", "warn")
if callback:
_cb_gateway = callback
if cookie:
try:
readyfunc = getattr (item, 'ready')
except AttributeError:
pass
else:
if not readyfunc ():
return self.l.append (item)
return self.l.appendleft (item)
def clear (self):
self.l.clear ()
self.has_None = False
class await_ts_fifo (await_fifo):
# HTTP/1.x needn't this class, because one channel handles only one request
# this will be used for handling multiple requests like HTTP/2
def __init__ (self):
await_fifo.__init__ (self)
self._lock = threading.Lock ()
def working (self):
with self._lock:
return await_fifo.working (self)
def __len__ (self):
with self._lock:
return await_fifo.__len__ (self)
def __getitem__(self, index):
def working (self):
with self._lock:
return await_fifo.working (self)