diff --git a/docs/sphinx/source/whatsnew/v0.7.0.rst b/docs/sphinx/source/whatsnew/v0.7.0.rst index a8b2f21ebd..a1b616e804 100644 --- a/docs/sphinx/source/whatsnew/v0.7.0.rst +++ b/docs/sphinx/source/whatsnew/v0.7.0.rst @@ -20,8 +20,14 @@ Testing * Added 30 minutes to timestamps in `test_psm3.csv` to match change in NSRDB (:issue:`733`) +Enhancements +~~~~~~~~~~~~ +* Add `timeout` to :py:func:`pvlib.iotools.get_psm3`. + + Contributors ~~~~~~~~~~~~ * Mark Campanellli (:ghuser:`markcampanelli`) * Will Holmgren (:ghuser:`wholmgren`) +* Cliff Hansen (:ghuser:`cwhanse`) * Oscar Dowson (:ghuser:`odow`) diff --git a/pvlib/iotools/psm3.py b/pvlib/iotools/psm3.py index 560a259962..fb45f322e6 100644 --- a/pvlib/iotools/psm3.py +++ b/pvlib/iotools/psm3.py @@ -23,7 +23,7 @@ def get_psm3(latitude, longitude, api_key, email, names='tmy', interval=60, - full_name=PVLIB_PYTHON, affiliation=PVLIB_PYTHON): + full_name=PVLIB_PYTHON, affiliation=PVLIB_PYTHON, timeout=30): """ Get PSM3 data @@ -47,6 +47,8 @@ def get_psm3(latitude, longitude, api_key, email, names='tmy', interval=60, optional affiliation : str, default 'pvlib python' optional + timeout : int, default 30 + time in seconds to wait for server response before timeout Returns ------- @@ -144,7 +146,7 @@ def get_psm3(latitude, longitude, api_key, email, names='tmy', interval=60, 'interval': interval } # request CSV download from NREL PSM3 - response = requests.get(URL, params=params) + response = requests.get(URL, params=params, timeout=timeout) if not response.ok: # if the API key is rejected, then the response status will be 403 # Forbidden, and then the error is in the content and there is no JSON