File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,6 +60,10 @@ The following packages must be installed to run this notebook.
6060## 4. Imports
6161
6262``` {code-cell} ipython3
63+ import http.client
64+ import time
65+ import urllib.error
66+
6367import numpy as np
6468import matplotlib.pyplot as plt
6569
@@ -155,7 +159,16 @@ You can put this URL into a browser to download the file. Or you can work with i
155159Use Astropy to examine the header of the URL from the previous step.
156160
157161``` {code-cell} ipython3
158- hdulist = fits.open(spectral_image_url)
162+ Max number of times to retry HTTP errors.
163+ max_retries = 3
164+ for attempt in range(max_retries):
165+ try:
166+ hdulist = fits.open(spectral_image_url)
167+ break
168+ except (urllib.error.HTTPError, http.client.IncompleteRead):
169+ if attempt == max_retries - 1:
170+ raise
171+ time.sleep(10 * (attempt + 1))
159172hdulist.info()
160173```
161174
You can’t perform that action at this time.
0 commit comments