diff --git a/swh/loader/mercurial/hgutil.py b/swh/loader/mercurial/hgutil.py --- a/swh/loader/mercurial/hgutil.py +++ b/swh/loader/mercurial/hgutil.py @@ -2,6 +2,7 @@ # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information + from collections import defaultdict from dataclasses import dataclass import io @@ -154,7 +155,7 @@ if process.is_alive(): process.terminate() - # Give it a second (literally), then kill it + # Give it literally a second (in successive steps of 0.1 second), then kill it. # Can't use `process.join(1)` here, billiard appears to be bugged # https://github.com/celery/billiard/issues/270 killed = False diff --git a/swh/loader/mercurial/tests/test_hgutil.py b/swh/loader/mercurial/tests/test_hgutil.py --- a/swh/loader/mercurial/tests/test_hgutil.py +++ b/swh/loader/mercurial/tests/test_hgutil.py @@ -15,12 +15,14 @@ def test_clone_timeout(monkeypatch): src = "https://www.mercurial-scm.org/repo/hello" dest = "/dev/null" - timeout = 0.1 + timeout = 1 + sleepy_time = 100 * timeout + assert sleepy_time > timeout def clone(*args, **kwargs): # ignore SIGTERM to force sigkill signal.signal(signal.SIGTERM, lambda signum, frame: None) - time.sleep(2) + time.sleep(sleepy_time) # we make sure we exceed the timeout monkeypatch.setattr(hg, "clone", clone)