Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def test_hsession_smallpool():
from asks.sessions import Session
s = Session('http://httpbin.org', connections=2)
async with curio.TaskGroup() as g:
for _ in range(10):
await g.spawn(hsession_t_smallpool(s))
async def main(coro, *server_coros):
async with curio.TaskGroup() as g:
for server_coro in server_coros:
await g.spawn(server_coro)
task = await g.spawn(coro)
await task.join()
await g.cancel_remaining()
async def main(c1, c2):
async with TaskGroup() as g:
await g.spawn(server, c1)
await g.spawn(client, c2)
async def main(ch1, ch2):
async with TaskGroup() as g:
await g.spawn(server, ch1)
await g.spawn(client, ch2)
async def main(c1, c2):
async with TaskGroup() as g:
await g.spawn(server, c1)
await g.spawn(client, c2)
async def main(ch1, ch2):
async with TaskGroup() as g:
await g.spawn(server, ch1)
await g.spawn(client, ch2)
async def relay(self, via_client):
try:
async with curio.TaskGroup() as g:
await g.spawn(self._relay(via_client))
await g.spawn(self._reverse_relay(via_client))
await g.next_done(cancel_remaining=True)
except curio.TaskGroupError as e:
gvars.logger.debug(f"group error: {e}")
async def recv(self):
if not self.closed:
async with TaskGroup(wait=any) as g:
receiver = await g.spawn(self.incoming.get)
await g.spawn(self.closing.wait)
if g.completed is receiver:
return receiver.result
encoded = syncword.encode()
currently_running_urls = set()
async def listen_for_new_conns(task_group):
while True:
ch = Channel(chan)
try:
connection = await ch.accept(authkey=encoded)
mlog.info(f'new connection created {connection}')
await task_group.spawn(manage_single_connection,
connection,
currently_running_urls)
await ch.close() # sort of strange that we need this? can we connect again later !?
except ConnectionResetError as e:
mlog.warning('client connection attempt did not terminate property')
async with TaskGroup(name='manager') as connection_tasks:
await connection_tasks.spawn(exit, connection_tasks)
await connection_tasks.spawn(listen_for_new_conns, connection_tasks)
async def create_many_outer():
async with curio.TaskGroup() as task:
for name in names:
await task.spawn(connect_one, name)
while True:
res = await task.next_done()
if res is None:
break
name, chan = res.result
channels[name] = chan