2

There seems to be lots of questions on this topic bit I can't seem to find what exactly I should call inside my python script to increase the open file limit ? I know that I need to use the _setmaxstdio on C level but I am not sure how to call it in python. Any ideas ?

Cemre Mengü
  • 18,062
  • 27
  • 111
  • 169
  • Isn't @NorthCat answer OK? If yes, please mark it as so. Also: https://stackoverflow.com/questions/6774724/why-python-has-limit-for-count-of-file-handles. – CristiFati Apr 05 '20 at 20:33

2 Answers2

3

Try to use win32file from pywin32:

import win32file
print win32file._getmaxstdio() #512

win32file._setmaxstdio(1024)
print win32file._getmaxstdio() #1024
NorthCat
  • 9,643
  • 16
  • 47
  • 50
0

One more solution with the built-in ctypes library:

import ctypes
print("Before: {}".format(ctypes.windll.msvcrt._getmaxstdio()))
ctypes.windll.msvcrt._setmaxstdio(2048)
print("After: {}".format(ctypes.windll.msvcrt._getmaxstdio()))
ababak
  • 1,685
  • 1
  • 11
  • 23