10000 Double pip timeout each time it times out (#2296) · ag-python-qt/mu-pyqt@b71af75 · GitHub
[go: up one dir, main page]

Skip to content

Commit b71af75

Browse files
tonybaloneytjguk
andauthored
Double pip timeout each time it times out (mu-editor#2296)
* Use the MU_LOG_TO_STDOUT envvar to turn on stdout logging and to disable the crash handler Use version-tagged zips for the downloaded packages * Refactor slightly partly to support easier testing * Test the right exception if the download fails * Pushing latest changes although incomplete -- Still tests failing and some coverage missing after refactor * Iterate over the files in the folder, not the name of the folder(!) * Ensure we can use glob * Tidy * Ignore generated zip files * Refactor baseline install test to allow for the fact that we now install from zips, not from files * Tweak tests for logging setup to allow for MU_LOG_TO_STDOUT env var * Tidy * Disable the pip version check when downloading wheels Always add the temp download area to the search patch for downloading wheels. This should work for the MacOS shim where we have to download a signed wheel for pygame and then be sure to use that in preference to the PyPI version * Add more useful function comments Remove (again) `upgrade_pip` + Tidy * expand error message for process timeout * double timeout each time virtualenv install fails * add stdout/err to exception message in timeout case as well --------- Co-authored-by: Tim Golden <mail@timgolden.me.uk>
1 parent 2ae7447 commit b71af75

File tree

1 file changed

+39
-6
lines changed

1 file changed

+39
-6
lines changed

mu/virtual_environment.py

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ def __init__(self, message):
5858
self.message = message
5959

6060

61+
class VirtualEnvironmentTimeoutError(VirtualEnvironmentError):
62+
def __init__(self, message, timeout):
63+
super().__init__(message)
64+
self.timeout = timeout
65+
66+
6167
class VirtualEnvironmentEnsureError(VirtualEnvironmentError):
6268
pass
6369

@@ -198,7 +204,21 @@ def wait(self, wait_for_s=30):
198204
# generate a URI out of it. There's an upper limit on URI size of ~2000
199205
#
200206
if not finished:
201-
logger.error(compact(output))
207+
if exit_code and compact(output):
208+
logger.error(compact(output))
209+
elif exit_code:
210+
logger.error(
211+
"Process failed with exit code %s but provided no message",
212+
exit_code,
213+
)
214+
else:
215+
logger.error("Virtual environment creation timed out")
216+
raise VirtualEnvironmentTimeoutError(
217+
"Virtual environment creation timed out:\n"
218+
+ compact(output),
219+
wait_for_s,
220+
)
221+
202222
raise VirtualEnvironmentError(
203223
"Process did not terminate normally:\n" + compact(output)
204224
)
@@ -242,9 +262,10 @@ class Pip(object):
242262
def __init__(self, pip_executable):
243263
self.executable = pip_executable
244264
self.process = Process()
265+
self.timeout = 180.0
245266

246267
def run(
247-
self, command, *args, wait_for_s=120.0, slots=Process.Slots(), **kwargs
268+
self, command, *args, wait_for_s=None, slots=Process.Slots(), **kwargs
248269
):
249270
"""
250271
Run a command with args, treating kwargs as Posix switches.
@@ -257,6 +278,8 @@ def run(
257278
# As a special case, a boolean value indicates that the flag
258279
# is a yes/no switch
259280
#
281+
if not wait_for_s:
282+
wait_for_s = self.timeout
260283
params = [command, "--disable-pip-version-check"]
261284
for k, v in kwargs.items():
262285
switch = k.replace("_", "-")
@@ -293,11 +316,19 @@ def install(self, packages, slots=Process.Slots(), **kwargs):
293316
"""
294317
if isinstance(packages, str):
295318
return self.run(
296-
"install", packages, wait_for_s=180.0, slots=slots, **kwargs
319+
"install",
320+
packages,
321+
wait_for_s=self.timeout,
322+
slots=slots,
323+
**kwargs
297324
)
298325
else:
299326
return self.run(
300-
"install", *packages, wait_for_s=180.0, slots=slots, **kwargs
327+
"install",
328+
*packages,
329+
wait_for_s=self.timeout,
330+
slots=slots,
331+
**kwargs
301332
)
302333

303334
def uninstall(self, packages, slots=Process.Slots(), **kwargs):
@@ -314,7 +345,7 @@ def uninstall(self, packages, slots=Process.Slots(), **kwargs):
314345
return self.run(
315346
"uninstall",
316347
packages,
317-
wait_for_s=180.0,
348+
wait_for_s=self.timeout,
318349
slots=slots,
319350
yes=True,
320351
**kwargs
@@ -323,7 +354,7 @@ def uninstall(self, packages, slots=Process.Slots(), **kwargs):
323354
return self.run(
324355
"uninstall",
325356
*packages,
326-
wait_for_s=180.0,
357+
wait_for_s=self.timeout,
327358
slots=slots,
328359
yes=True,
329360
**kwargs
@@ -679,6 +710,8 @@ def ensure_and_create(self, emitter=None):
679710
if n < n_tries:
680711
self.relocate(self._generate_dirpath())
681712
try_to_create = True
713+
if isinstance(exc, VirtualEnvironmentTimeoutError):
714+
self.pip.timeout = exc.timeout * 2
682715
n += 1
683716
else:
684717
raise

0 commit comments

Comments
 (0)
0