mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 16:59:47 +00:00
Increase file descriptor limit when running test.py on MacOS
This is an attempt to solve io test flakiness on MacOS. The symptoms include "connection refused", "broken pipe" error messages. Change-Id: If6759f4ef9cd2c1b9bd083db9a469db43f12c4e0 Reviewed-on: https://dart-review.googlesource.com/c/80120 Commit-Queue: Martin Kustermann <kustermann@google.com> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
This commit is contained in:
parent
5ce132a912
commit
ed73cc379d
|
@ -27,8 +27,9 @@ def Main():
|
||||||
os.environ['PATH'] = '%s%s%s' % (
|
os.environ['PATH'] = '%s%s%s' % (
|
||||||
os.environ['PATH'], os.pathsep, android_platform_tools)
|
os.environ['PATH'], os.pathsep, android_platform_tools)
|
||||||
|
|
||||||
with utils.CoreDumpArchiver(args):
|
with utils.FileDescriptorLimitIncreaser():
|
||||||
exit_code = subprocess.call(command)
|
with utils.CoreDumpArchiver(args):
|
||||||
|
exit_code = subprocess.call(command)
|
||||||
|
|
||||||
utils.DiagnoseExitCode(exit_code, command)
|
utils.DiagnoseExitCode(exit_code, command)
|
||||||
return exit_code
|
return exit_code
|
||||||
|
|
|
@ -1056,9 +1056,20 @@ class WindowsCoreDumpArchiver(BaseCoreDumpArchiver):
|
||||||
missing_as_string = ', '.join([str(c) for c in missing])
|
missing_as_string = ', '.join([str(c) for c in missing])
|
||||||
raise Exception('Missing crash dumps for: %s' % missing_as_string)
|
raise Exception('Missing crash dumps for: %s' % missing_as_string)
|
||||||
|
|
||||||
|
class IncreasedNumberOfFileDescriptors(object):
|
||||||
|
def __init__(self, nofiles):
|
||||||
|
self._old_limits = None
|
||||||
|
self._limits = (nofiles, nofiles)
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
self._old_limits = resource.getrlimit(resource.RLIMIT_NOFILE)
|
||||||
|
resource.setrlimit(resource.RLIMIT_NOFILE, self._limits)
|
||||||
|
|
||||||
|
def __exit__(self, *_):
|
||||||
|
resource.setrlimit(resource.RLIMIT_CORE, self._old_limits)
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def NooptCoreDumpArchiver():
|
def NooptContextManager():
|
||||||
yield
|
yield
|
||||||
|
|
||||||
|
|
||||||
|
@ -1068,7 +1079,7 @@ def CoreDumpArchiver(args):
|
||||||
output_directory = next((arg[len(prefix):] for arg in args if arg.startswith(prefix)), None)
|
output_directory = next((arg[len(prefix):] for arg in args if arg.startswith(prefix)), None)
|
||||||
|
|
||||||
if not enabled:
|
if not enabled:
|
||||||
return NooptCoreDumpArchiver()
|
return NooptContextManager()
|
||||||
|
|
||||||
osname = GuessOS()
|
osname = GuessOS()
|
||||||
if osname == 'linux':
|
if osname == 'linux':
|
||||||
|
@ -1082,8 +1093,16 @@ def CoreDumpArchiver(args):
|
||||||
WindowsCoreDumpArchiver(output_directory))
|
WindowsCoreDumpArchiver(output_directory))
|
||||||
else:
|
else:
|
||||||
# We don't have support for MacOS yet.
|
# We don't have support for MacOS yet.
|
||||||
assert osname == 'macos'
|
return NooptContextManager()
|
||||||
return NooptCoreDumpArchiver()
|
|
||||||
|
def FileDescriptorLimitIncreaser():
|
||||||
|
osname = GuessOS()
|
||||||
|
if osname == 'macos':
|
||||||
|
return IncreasedNumberOfFileDescriptors(nofiles=10000)
|
||||||
|
else:
|
||||||
|
assert osname in ('linux', 'win32')
|
||||||
|
# We don't have support for MacOS yet.
|
||||||
|
return NooptContextManager()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import sys
|
import sys
|
||||||
|
|
Loading…
Reference in a new issue