Skip to content

Add check for empty socket.error args#1580

Open
gustafsson wants to merge 1 commit into
GoogleCloudPlatform:masterfrom
gustafsson:patch-1
Open

Add check for empty socket.error args#1580
gustafsson wants to merge 1 commit into
GoogleCloudPlatform:masterfrom
gustafsson:patch-1

Conversation

@gustafsson
Copy link
Copy Markdown

When doing a

gsutil cp myfile gs://mybucket/name

With a https_proxy that was limiting the number of concurrent sockets. I got a

socket.timeout: timed out

During handling of the above exception, another exception occurred:
...
socks.GeneralProxyError: Socket error: timed out

During handling of the above exception, another exception occurred:
...
~/Applications/google-cloud-sdk/platform/gsutil/gslib/gcs_json_media.py", line 587, in _conn_request
    err = getattr(e, 'args')[0]

It seems socket.error can have empty args. This PR adds a check.

gsutil_IndexError_tuple_index_out_of_range.txt

Copy link
Copy Markdown
Collaborator

@dilipped dilipped left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late response here and thanks for the PR. Can you please add tests for the change? The test can go in the file tests/test_gcs_json_media.py.

Comment thread gslib/gcs_json_media.py
except socket.error as e:
err = 0
if hasattr(e, 'args'):
if hasattr(e, 'args') and getattr(e, 'args'):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can replace the entire line with if getattr(e, 'args', None)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants