From cd1cf2d86ac1c7d16f59ce91a197cd10c3b201e9 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 1 Sep 2023 11:41:08 -0400 Subject: [PATCH] Extend timeout more --- .github/workflows/main.yml | 2 ++ jaraco/mongodb/service.py | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 158e116..bde8fbd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,6 +26,8 @@ env: PY_COLORS PYTEST_THEME PYTEST_THEME_MODE + GITHUB_* + RUNNER_* # Suppress noisy pip warnings PIP_DISABLE_PIP_VERSION_CHECK: 'true' diff --git a/jaraco/mongodb/service.py b/jaraco/mongodb/service.py index 8c14e6c..df6b322 100644 --- a/jaraco/mongodb/service.py +++ b/jaraco/mongodb/service.py @@ -104,6 +104,18 @@ def merge_mongod_args(self, add_args): self.port, add_args[:] = cli.extract_param('port', add_args, type=int) self.mongod_args = add_args + @property + def _startup_timeout(self): + """ + On GitHub Actions on Windows, MongoDB takes forever to + start, but starts up fast locally and on other platforms. + """ + slow = ( + os.environ.get('GITHUB_ACTIONS') + and os.environ.get('RUNNER_OS') == 'Windows' + ) + return 120 if slow else 10 + def start(self): super(MongoDBInstance, self).start() if not hasattr(self, 'port') or not self.port: @@ -119,7 +131,7 @@ def start(self): if hasattr(self, 'bind_ip') and '--bind_ip' not in cmd: cmd.extend(['--bind_ip', self.bind_ip]) self.process = subprocess.Popen(cmd, **self.process_kwargs) - portend.occupied('localhost', self.port, timeout=10) + portend.occupied('localhost', self.port, timeout=self._startup_timeout) log.info(f'{self} listening on {self.port}') def get_connection(self):