From 2279a8a80e509c519eb86631a1a0127bd69ec3f4 Mon Sep 17 00:00:00 2001 From: Martin Bornhold Date: Tue, 4 Oct 2016 12:53:40 +0200 Subject: [PATCH] vcs: Fix vcsserver startup with http backend. --- rhodecode/lib/vcs/__init__.py | 18 +++++++++++------- rhodecode/lib/vcs/exceptions.py | 3 +-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/rhodecode/lib/vcs/__init__.py b/rhodecode/lib/vcs/__init__.py index ea4357c2..680d71c3 100644 --- a/rhodecode/lib/vcs/__init__.py +++ b/rhodecode/lib/vcs/__init__.py @@ -46,7 +46,7 @@ from Pyro4.errors import CommunicationError from rhodecode.lib.vcs.conf import settings from rhodecode.lib.vcs.backends import get_vcs_instance, get_backend from rhodecode.lib.vcs.exceptions import ( - VCSError, RepositoryError, CommitError) + VCSError, RepositoryError, CommitError, VCSCommunicationError) log = logging.getLogger(__name__) @@ -180,7 +180,7 @@ def _start_http_vcs_server(server_and_port, log_level=None): host, port = server_and_port.rsplit(":", 1) args = [ - 'pserve', 'vcsserver/development_pyramid.ini', + 'pserve', 'rhodecode/tests/vcsserver_http.ini', 'http_port=%s' % (port, ), 'http_host=%s' % (host, )] proc = subprocess.Popen(args) @@ -192,14 +192,18 @@ def _start_http_vcs_server(server_and_port, log_level=None): _wait_until_vcs_server_is_reachable(server) -def _wait_until_vcs_server_is_reachable(server): - while xrange(80): # max 40s of sleep +def _wait_until_vcs_server_is_reachable(server, timeout=40): + begin = time.time() + while (time.time() - begin) < timeout: try: server.ping() - break - except (CommunicationError, pycurl.error): - pass + return + except (VCSCommunicationError, CommunicationError, pycurl.error): + log.debug('VCSServer not started yet, retry to connect.') time.sleep(0.5) + raise Exception( + 'Starting the VCSServer failed or took more than {} ' + 'seconds.'.format(timeout)) def _try_to_shutdown_running_server(server_and_port, protocol): diff --git a/rhodecode/lib/vcs/exceptions.py b/rhodecode/lib/vcs/exceptions.py index c0d8f409..4a9b5f68 100644 --- a/rhodecode/lib/vcs/exceptions.py +++ b/rhodecode/lib/vcs/exceptions.py @@ -24,8 +24,7 @@ Custom vcs exceptions module. import functools import urllib2 -import pycurl -from Pyro4.errors import CommunicationError + class VCSCommunicationError(Exception): pass