timeout in testserver
This commit is contained in:
		
							parent
							
								
									b007586076
								
							
						
					
					
						commit
						edb8d6e863
					
				|  | @ -16,7 +16,8 @@ class RequestHandler(http.server.SimpleHTTPRequestHandler): | ||||||
|             apiurl=self.server.proxyUrl |             apiurl=self.server.proxyUrl | ||||||
|             url=apiurl+p.replace("/api","") |             url=apiurl+p.replace("/api","") | ||||||
|             print("proxy to %s"%url) |             print("proxy to %s"%url) | ||||||
|             with urllib.request.urlopen(url) as response: |             try: | ||||||
|  |                 with urllib.request.urlopen(url,timeout=10) as response: | ||||||
|                     self.send_response(http.HTTPStatus.OK) |                     self.send_response(http.HTTPStatus.OK) | ||||||
|                     self.send_header("Content-type", response.getheader("Content-type")) |                     self.send_header("Content-type", response.getheader("Content-type")) | ||||||
|                  |                  | ||||||
|  | @ -25,6 +26,9 @@ class RequestHandler(http.server.SimpleHTTPRequestHandler): | ||||||
|                 return None |                 return None | ||||||
|                 self.send_error(http.HTTPStatus.NOT_FOUND, "api not found") |                 self.send_error(http.HTTPStatus.NOT_FOUND, "api not found") | ||||||
|                 return None |                 return None | ||||||
|  |             except Exception as e: | ||||||
|  |                 self.send_error(http.HTTPStatus.INTERNAL_SERVER_ERROR, "api error %s"%str(e)) | ||||||
|  |                 return None | ||||||
|         super().do_GET()         |         super().do_GET()         | ||||||
|     def translate_path(self, path): |     def translate_path(self, path): | ||||||
|         """Translate a /-separated PATH to the local filename syntax. |         """Translate a /-separated PATH to the local filename syntax. | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 andreas
						andreas