Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch OSError instead of StreamClosedError #8937

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions distributed/comm/tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ async def read(self, deserializers=None):
buffer = await read_bytes_rw(stream, buffer_nbytes)
frames.append(buffer)

except StreamClosedError as e:
except OSError as e:
self.stream = None
self._closed = True
convert_stream_closed_error(self, e)
Expand Down Expand Up @@ -301,7 +301,7 @@ async def write(self, msg, serializers=None, on_error="message"):

# start writing frames
stream.write(b"")
except StreamClosedError as e:
except OSError as e:
self.stream = None
self._closed = True
convert_stream_closed_error(self, e)
Expand Down Expand Up @@ -554,16 +554,16 @@ async def connect(self, address, deserialize=True, **connection_args):
if stream.closed() and stream.error:
raise StreamClosedError(stream.error)

except StreamClosedError as e:
# The socket connect() call failed
convert_stream_closed_error(self, e)
except SSLCertVerificationError as err:
raise FatalCommClosedError(
"TLS certificate does not match. Check your security settings. "
"More info at https://distributed.dask.org/en/latest/tls.html"
) from err
except SSLError as err:
raise FatalCommClosedError() from err
except OSError as e:
# The socket connect() call failed
convert_stream_closed_error(self, e)

local_address = self.prefix + get_stream_address(stream)
comm = self.comm_class(
Expand Down
4 changes: 2 additions & 2 deletions distributed/comm/ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,15 +443,15 @@
sock = await websocket_connect(request, max_message_size=MAX_MESSAGE_SIZE)
if sock.stream.closed() and sock.stream.error:
raise StreamClosedError(sock.stream.error)
except StreamClosedError as e:
convert_stream_closed_error(self, e)
except SSLError as err:
raise FatalCommClosedError(
"TLS expects a `ssl_context` argument of type "
"ssl.SSLContext (perhaps check your TLS configuration?)"
) from err
except HTTPClientError as e:
raise CommClosedError(f"in {self}: {e}") from e
except OSError as e:
convert_stream_closed_error(self, e)

Check warning on line 454 in distributed/comm/ws.py

View check run for this annotation

Codecov / codecov/patch

distributed/comm/ws.py#L453-L454

Added lines #L453 - L454 were not covered by tests
return self.comm_class(sock, deserialize=deserialize)

def _get_connect_args(self, **connection_args):
Expand Down
Loading