Use msvcrt 110 and 120 when 110 is not avaliable

This commit is contained in:
shortcutme 2020-01-04 16:48:37 +01:00
parent aec1ab4ed2
commit b6d0bf8f6b
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE

View file

@ -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