File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed
Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -246,11 +246,22 @@ def increase_open_file_limit():
246246 limit is much higher.
247247 """
248248 soft , hard = resource .getrlimit (resource .RLIMIT_NOFILE )
249- if soft < hard :
250- LOG .debug ('raising soft open file limit from %d to %d' , soft , hard )
251- resource .setrlimit (resource .RLIMIT_NOFILE , (hard , hard ))
252- else :
253- LOG .debug ('cannot increase open file limit; existing limit is %d' , hard )
249+ LOG .debug ('inherited open file limits: soft=%d hard=%d' , soft , hard )
250+ if soft >= hard :
251+ LOG .debug ('max open files already set to hard limit: %d' , hard )
252+ return
253+
254+ # OS X is limited by kern.maxfilesperproc sysctl, rather than the
255+ # advertised unlimited hard RLIMIT_NOFILE. Just hard-wire known defaults
256+ # for that sysctl, to avoid the mess of querying it.
257+ for value in (hard , 10240 ):
258+ try :
259+ resource .setrlimit (resource .RLIMIT_NOFILE , (value , hard ))
260+ LOG .debug ('raised soft open file limit from %d to %d' , soft , value )
261+ break
262+ except ValueError as e :
263+ LOG .debug ('could not raise soft open file limit from %d to %d: %s' ,
264+ soft , value , e )
254265
255266
256267def common_setup (enable_affinity = True , _init_logging = True ):
You can’t perform that action at this time.
0 commit comments