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

Fix image grab/timeout issue #14

Open
astrobokonon opened this issue Aug 26, 2020 · 2 comments
Open

Fix image grab/timeout issue #14

astrobokonon opened this issue Aug 26, 2020 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@astrobokonon
Copy link
Member

astrobokonon commented Aug 26, 2020

Downloading an image from dct-allsky failed, in the middle of grabbing the image, and things just hung.

2020-08-26 00:48:58,343 INFO     Retrieving camera image: DCTAllSky
2020-08-26 00:48:58,368 INFO     Attempting to write image to ./outputs/images/dct//allsky.jpg
2020-08-26 00:48:58,369 INFO     Retrieving image from: http://dct-allsky.lowell.edu/allsky//as20200825_125046.jpg

It hung for hours there until someone noticed, so I restarted by hand and now the errors are getting trapped properly and timing out.

2020-08-26 02:28:05,651 INFO     Username None in section DomeRoof has no password!
2020-08-26 02:28:05,652 INFO     Found the following sections in the configuration file:
2020-08-26 02:28:05,652 INFO     UpperGate HeliumCompressor Genset TelescopeBuilding UtilityYard ObservingLevel DomeRoof DCTAllSky
2020-08-26 02:28:05,652 INFO     Enabled:
2020-08-26 02:28:05,652 INFO     UpperGate HeliumCompressor Genset TelescopeBuilding UtilityYard ObservingLevel DomeRoof DCTAllSky
2020-08-26 02:28:05,653 INFO     Retrieving camera image: UpperGate
2020-08-26 02:28:05,653 INFO     Attempting to write image to ./outputs/images/dct//gate.jpg
2020-08-26 02:28:05,718 INFO     Good grab!
2020-08-26 02:28:06,219 INFO     Retrieving camera image: HeliumCompressor
2020-08-26 02:28:06,219 INFO     Attempting to write image to ./outputs/images/dct//heliumcomp.jpg
2020-08-26 02:28:06,223 INFO     HTTPConnectionPool(host='10.11.131.61', port=80): Max retries exceeded with url: /image/jpeg.cgi (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7ff24c90afd0>: Failed to establish a new connection: [Errno 111] Connection refused'))
2020-08-26 02:28:06,748 INFO     Retrieving camera image: Genset
2020-08-26 02:28:06,748 INFO     Attempting to write image to ./outputs/images/dct//genset.jpg
2020-08-26 02:28:06,808 INFO     Good grab!
2020-08-26 02:28:07,309 INFO     Retrieving camera image: TelescopeBuilding
2020-08-26 02:28:07,310 INFO     Attempting to write image to ./outputs/images/dct//tel_bldg.jpg
2020-08-26 02:28:12,317 INFO     HTTPConnectionPool(host='10.11.131.63', port=80): Max retries exceeded with url: /cgi-bin/video.jpg (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7ff24c8a5f50>, 'Connection to 10.11.131.63 timed out. (connect timeout=5.0)'))
2020-08-26 02:28:12,835 INFO     Retrieving camera image: UtilityYard
2020-08-26 02:28:12,835 INFO     Attempting to write image to ./outputs/images/dct//util_yard.jpg
2020-08-26 02:28:17,841 INFO     HTTPConnectionPool(host='10.11.131.64', port=80): Max retries exceeded with url: /cgi-bin/video.jpg (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7ff24c8ac450>, 'Connection to 10.11.131.64 timed out. (connect timeout=5.0)'))
2020-08-26 02:28:18,360 INFO     Retrieving camera image: ObservingLevel
2020-08-26 02:28:18,360 INFO     Attempting to write image to ./outputs/images/dct//obs_level.jpg
2020-08-26 02:28:18,406 INFO     Good grab!
2020-08-26 02:28:18,907 INFO     Retrieving camera image: DomeRoof
2020-08-26 02:28:18,908 INFO     Attempting to write image to ./outputs/images/dct//dome_roof.jpg
2020-08-26 02:28:18,967 INFO     Good grab!
2020-08-26 02:28:19,468 INFO     Retrieving camera image: DCTAllSky
2020-08-26 02:28:22,546 INFO     HTTPConnectionPool(host='dct-allsky.lowell.edu', port=80): Max retries exceeded with url: /allsky/ (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7ff24c8b8e50>: Failed to establish a new connection: [Errno 113] No route to host'))
@astrobokonon astrobokonon added the bug Something isn't working label Aug 26, 2020
@astrobokonon astrobokonon self-assigned this Aug 26, 2020
@astrobokonon
Copy link
Member Author

astrobokonon commented Aug 27, 2020

A quick look suggests that this is buried down deep in nightshift.webcam.grab_cams.simpleImageCopy, specifically here:

print("Attempting to write image to %s" % (location))
with open(location, "wb") as f:
print('Retrieving image from: %s' % (url))
img = httpget(url)
f.write(img.content)

Seems like I'm just calling get (renamed to httpget in the import) from requests

@astrobokonon
Copy link
Member Author

https://requests.readthedocs.io/en/latest/api/#requests.request suggests I can just slap a timeout= keyword in here, since requests.get is really just requests.request("GET", ...) and handle the exception appropriately (if it's not already caught earlier in the call chain that gets here).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant