MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / _async_socket_sendall_ssl

Function _async_socket_sendall_ssl

pymongo/network_layer.py:93–134  ·  view source on GitHub ↗
(
        sock: Union[socket.socket, _sslConn], buf: bytes, loop: AbstractEventLoop
    )

Source from the content-addressed store, hash-verified

91if sys.platform != "win32":
92
93 async def _async_socket_sendall_ssl(
94 sock: Union[socket.socket, _sslConn], buf: bytes, loop: AbstractEventLoop
95 ) -> None:
96 view = memoryview(buf)
97 sent = 0
98
99 def _is_ready(fut: Future[Any]) -> None:
100 if fut.done():
101 return
102 fut.set_result(None)
103
104 while sent < len(buf):
105 try:
106 sent += sock.send(view[sent:])
107 except BLOCKING_IO_ERRORS as exc:
108 fd = sock.fileno()
109 # Check for closed socket.
110 if fd == -1:
111 raise SSLError("Underlying socket has been closed") from None
112 if isinstance(exc, BLOCKING_IO_READ_ERROR):
113 fut = loop.create_future()
114 loop.add_reader(fd, _is_ready, fut)
115 try:
116 await fut
117 finally:
118 loop.remove_reader(fd)
119 if isinstance(exc, BLOCKING_IO_WRITE_ERROR):
120 fut = loop.create_future()
121 loop.add_writer(fd, _is_ready, fut)
122 try:
123 await fut
124 finally:
125 loop.remove_writer(fd)
126 if _HAVE_PYOPENSSL and isinstance(exc, BLOCKING_IO_LOOKUP_ERROR):
127 fut = loop.create_future()
128 loop.add_reader(fd, _is_ready, fut)
129 try:
130 loop.add_writer(fd, _is_ready, fut)
131 await fut
132 finally:
133 loop.remove_reader(fd)
134 loop.remove_writer(fd)
135
136 async def _async_socket_receive_ssl(
137 conn: _sslConn, length: int, loop: AbstractEventLoop, once: Optional[bool] = False

Callers 1

async_socket_sendallFunction · 0.85

Calls 2

SSLErrorClass · 0.90
filenoMethod · 0.45

Tested by

no test coverage detected