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

DRMS Client class URL requests fail to timeout #53

Open
dkempton opened this issue Jan 15, 2021 · 0 comments
Open

DRMS Client class URL requests fail to timeout #53

dkempton opened this issue Jan 15, 2021 · 0 comments

Comments

@dkempton
Copy link

dkempton commented Jan 15, 2021

Description

When making URL requests via the DRMS Client class, network connections do not timeout and fail gracefully. This leads to requests such as "query", "export", and "download" to stall indefinitely when the server fails to respond, requiring a program restart to recover.

Expected vs Actual behavior

When making requests such as "query", "export", and "download" using the Client class, it is expected that the network communication should timeout and possibly return some sort of network timeout error if a response is not received from the requested server. Alternatively, the Client could capture such errors and attempt a retry itself. This, however, is not the behavior exhibited by the Client class.

Steps to Reproduce

This is an intermittent issue when in actual production, but one could possibly reproduce by severing network connection prior to or in the middle of making such requests.

The root cause of this issue is most likely in the drms/json.py module line 66, and in the drms/client.py module line 591

The json.py module might be fixed by providing a default timeout value to the urlopen method call. When none is provided, the method utilizes the socket._GLOBAL_DEFAULT_TIMEOUT as can be seen in the implementation code here. It is also mentioned in the documentation for the method here:

"The optional timeout parameter specifies a timeout in seconds for blocking operations like the connection attempt (if not specified, the global default timeout setting will be used)"

Though what is not mentioned is that the socket._GLOBAL_DEFAULT_TIMEOUT is set to None by default and therefore a timeout never occurs. This is, however, documented in the socket._GLOBAL_DEFAULT_TIMEOUT documentation:

"Return the default timeout in seconds (float) for new socket objects. A value of None indicates that new socket objects have no timeout. When the socket module is first imported, the default is None."

The drms/client.py is most likely caused by a similar assumption, but the urlretrieve method does not provide for supplying a timeout, so some other solution would be necessary, such as replacing urlretrieve with urlopen so that a default timeout can be provided.

Alternatively, a solution to both may be to utilize the socket.setdefaulttimeout upon module import of both/either drms/json.py and/or drms/client.py.

System Details

  • SunPy Version: 2.0.4
  • Astropy Version: 4.1
  • Python Version: 3.7.8
  • OS information: Ubuntu Linux 20.04 (but this will occur with all operating systems as it comes from improper assumptions about socket._GLOBAL_DEFAULT_TIMEOUT)
@nabobalis nabobalis added the Bug label Jan 15, 2021
@github-actions github-actions bot removed the Bug label Nov 12, 2024
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

No branches or pull requests

2 participants