File tree 1 file changed +18
-0
lines changed 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -633,6 +633,24 @@ def cleanup(self):
633
633
print ("Remove file: %s" % name )
634
634
os_helper .unlink (name )
635
635
636
+ def adjust_resource_limits (self ):
637
+ try :
638
+ import resource
639
+ from resource import RLIMIT_NOFILE , RLIM_INFINITY
640
+ except ImportError :
641
+ return
642
+ fd_limit , max_fds = resource .getrlimit (RLIMIT_NOFILE )
643
+ if fd_limit < 2000 and fd_limit < max_fds :
644
+ # On macOS the default fd limit is sometimes too low (256) for our
645
+ # test suite to succeed. Raise it to something more reasonable.
646
+ new_fd_limit = min (2000 , max_fds )
647
+ try :
648
+ resource .setrlimit (RLIMIT_NOFILE , (new_fd_limit , max_fds ))
649
+ print (f"Raised RLIMIT_NOFILE to { new_fd_limit } ." )
650
+ except (ValueError , OSError ) as err :
651
+ print (f"Unable to raise RLIMIT_NOFILE from { fd_limit } to "
652
+ f"{ new_fd_limit } : { err } " .)
653
+
636
654
def main (self , tests = None , ** kwargs ):
637
655
self .parse_args (kwargs )
638
656
You can’t perform that action at this time.
0 commit comments