Ejemplo n.º 1
0
async def wait_socket_writable(sock: socket.SocketType) -> None:
    check_cancelled()
    if _write_events.get(sock):
        raise ResourceBusyError('writing to') from None

    loop = get_running_loop()
    event = _write_events[sock] = asyncio.Event(loop=loop)
    loop.add_writer(sock.fileno(), event.set)
    try:
        await event.wait()
    finally:
        loop.remove_writer(sock)
        del _write_events[sock]

    if sock.fileno() == -1:
        raise ClosedResourceError
Ejemplo n.º 2
0
async def wait_socket_writable(sock: socket.SocketType) -> None:
    check_cancelled()
    loop = get_running_loop()
    event = asyncio.Event(loop=loop)
    loop.add_writer(sock.fileno(), event.set)
    try:
        await event.wait()
    finally:
        loop.remove_writer(sock)
Ejemplo n.º 3
0
def s1mple(s: socket.SocketType):
    for i in range(100):

        p = f'[print(x) for x in [[().__class__.__base__.__subclasses__()[{i}]]]]\n'

        s.sendall(bytes(p, 'utf8'))
        d = s.recv(8096).replace(b'\n', b'').decode().split('>>>')[0]
        print(f'[*] {d} : {i}')
        if i % 2 or s.fileno() == -1:
            s = connect()
Ejemplo n.º 4
0
async def wait_socket_writable(sock: socket.SocketType) -> None:
    check_cancelled()
    if _write_events.get(sock):
        raise ResourceBusyError('writing to') from None

    loop = get_running_loop()
    event = _write_events[sock] = asyncio.Event(loop=loop)
    loop.add_writer(sock.fileno(), event.set)
    try:
        await event.wait()
    finally:
        if _write_events.pop(sock, None) is not None:
            loop.remove_writer(sock)
            writable = True
        else:
            writable = False

    if not writable:
        raise ClosedResourceError