mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 11:49:12 +00:00 
			
		
		
		
	Attempt to fix the "too many open files" errors on several of the
buildbots that the new test_close_fds_when_max_fd_is_lowered test causes. It now leaves 10 more low fd's available.
This commit is contained in:
		
						commit
						69b778df5d
					
				
					 1 changed files with 6 additions and 4 deletions
				
			
		| 
						 | 
					@ -1933,13 +1933,15 @@ class POSIXProcessTestCase(BaseTestCase):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        open_fds = set()
 | 
					        open_fds = set()
 | 
				
			||||||
        # Add a bunch more fds to pass down.
 | 
					        # Add a bunch more fds to pass down.
 | 
				
			||||||
        for _ in range(10):
 | 
					        for _ in range(40):
 | 
				
			||||||
            fd = os.open("/dev/null", os.O_RDONLY)
 | 
					            fd = os.open("/dev/null", os.O_RDONLY)
 | 
				
			||||||
            open_fds.add(fd)
 | 
					            open_fds.add(fd)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Leave a two pairs of low ones available for use by the
 | 
					        # Leave a two pairs of low ones available for use by the
 | 
				
			||||||
        # internal child error pipe and the stdout pipe.
 | 
					        # internal child error pipe and the stdout pipe.
 | 
				
			||||||
        for fd in sorted(open_fds)[:4]:
 | 
					        # We also leave 10 more open as some Python buildbots run into
 | 
				
			||||||
 | 
					        # "too many open files" errors during the test if we do not.
 | 
				
			||||||
 | 
					        for fd in sorted(open_fds)[:14]:
 | 
				
			||||||
            os.close(fd)
 | 
					            os.close(fd)
 | 
				
			||||||
            open_fds.remove(fd)
 | 
					            open_fds.remove(fd)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1952,8 +1954,8 @@ class POSIXProcessTestCase(BaseTestCase):
 | 
				
			||||||
        import resource
 | 
					        import resource
 | 
				
			||||||
        rlim_cur, rlim_max = resource.getrlimit(resource.RLIMIT_NOFILE)
 | 
					        rlim_cur, rlim_max = resource.getrlimit(resource.RLIMIT_NOFILE)
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            # 9 is lower than the highest fds we are leaving open.
 | 
					            # 29 is lower than the highest fds we are leaving open.
 | 
				
			||||||
            resource.setrlimit(resource.RLIMIT_NOFILE, (9, rlim_max))
 | 
					            resource.setrlimit(resource.RLIMIT_NOFILE, (29, rlim_max))
 | 
				
			||||||
            # Launch a new Python interpreter with our low fd rlim_cur that
 | 
					            # Launch a new Python interpreter with our low fd rlim_cur that
 | 
				
			||||||
            # inherits open fds above that limit.  It then uses subprocess
 | 
					            # inherits open fds above that limit.  It then uses subprocess
 | 
				
			||||||
            # with close_fds=True to get a report of open fds in the child.
 | 
					            # with close_fds=True to get a report of open fds in the child.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue