【问题标题】:Python: Which command increases the number of open files on Windows?Python:哪个命令会增加 Windows 上打开文件的数量?
【发布时间】:2014-07-29 19:35:00
【问题描述】:

关于这个主题似乎有很多问题我似乎无法找到我应该在我的 python 脚本中调用什么来增加打开文件限制?我知道我需要在 C 级别使用_setmaxstdio,但我不确定如何在 python 中调用它。有什么想法吗?

【问题讨论】:

标签: python file io


【解决方案1】:

尝试从pywin32使用win32file

import win32file
print win32file._getmaxstdio() #512

win32file._setmaxstdio(1024)
print win32file._getmaxstdio() #1024

【讨论】:

    【解决方案2】:

    使用内置 ctypes 库的另一种解决方案:

    import ctypes
    print("Before: {}".format(ctypes.windll.msvcrt._getmaxstdio()))
    ctypes.windll.msvcrt._setmaxstdio(2048)
    print("After: {}".format(ctypes.windll.msvcrt._getmaxstdio()))
    

    【讨论】:

      猜你喜欢
      • 2014-06-23
      • 1970-01-01
      • 2018-06-08
      • 2018-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-19
      相关资源
      最近更新 更多