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
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)
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()
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