From b6d0bf8f6b0a550d037f909b9ccf4a0e4e33da10 Mon Sep 17 00:00:00 2001 From: shortcutme Date: Sat, 4 Jan 2020 16:48:37 +0100 Subject: [PATCH] Use msvcrt 110 and 120 when 110 is not avaliable --- src/util/Platform.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/util/Platform.py b/src/util/Platform.py index 74613302..5bdde2f8 100644 --- a/src/util/Platform.py +++ b/src/util/Platform.py @@ -6,10 +6,22 @@ def setMaxfilesopened(limit): try: if sys.platform == "win32": import ctypes - maxstdio = ctypes.cdll.msvcr100._getmaxstdio() + dll = None + last_err = None + for dll_name in ["msvcr100", "msvcr110", "msvcr120"]: + try: + dll = getattr(ctypes.cdll, dll_name) + break + except OSError as err: + last_err = err + + if not dll: + raise last_err + + maxstdio = dll._getmaxstdio() if maxstdio < limit: - logging.debug("Current maxstdio: %s, changing to %s..." % (maxstdio, limit)) - ctypes.cdll.msvcr100._setmaxstdio(limit) + logging.debug("%s: Current maxstdio: %s, changing to %s..." % (dll, maxstdio, limit)) + dll._setmaxstdio(limit) return True else: import resource