From 34e0a83b864a6dd3c0e0c1f0e3804317055cee3f Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Oct 31 2017 10:01:25 +0000 Subject: Add a timeout when trying to query jenkins This will avoid pagure-ci trying to contact a jenkins instance forever. Fixes https://pagure.io/pagure/issue/2649 Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure-ci/pagure_ci_server.py b/pagure-ci/pagure_ci_server.py index cd62419..16f3637 100644 --- a/pagure-ci/pagure_ci_server.py +++ b/pagure-ci/pagure_ci_server.py @@ -94,15 +94,19 @@ def handle_messages(): request.project_from.path) _log.info( 'Triggering the build at: %s, for repo: %s', url, repo) - requests.post( - url, - data={ - 'token': request.project.ci_hook.pagure_ci_token, - 'cause': pr_id, - 'REPO': repo, - 'BRANCH': branch - } - ) + try: + requests.post( + url, + data={ + 'token': request.project.ci_hook.pagure_ci_token, + 'cause': pr_id, + 'REPO': repo, + 'BRANCH': branch + }, + timeout=60, + ) + except requests.exceptions.Timeout as err: + _log.debug('Request timed-out: %s' % err) else: _log.warning('Un-supported CI type')