mirror of
https://github.com/dart-lang/sdk
synced 2024-09-06 00:59:09 +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,6 +27,7 @@ def Main():
|
|||
os.environ['PATH'] = '%s%s%s' % (
|
||||
os.environ['PATH'], os.pathsep, android_platform_tools)
|
||||
|
||||
with utils.FileDescriptorLimitIncreaser():
|
||||
with utils.CoreDumpArchiver(args):
|
||||
exit_code = subprocess.call(command)
|
||||
|
||||
|
|
|
@ -1056,9 +1056,20 @@ class WindowsCoreDumpArchiver(BaseCoreDumpArchiver):
|
|||
missing_as_string = ', '.join([str(c) for c in missing])
|
||||
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
|
||||
def NooptCoreDumpArchiver():
|
||||
def NooptContextManager():
|
||||
yield
|
||||
|
||||
|
||||
|
@ -1068,7 +1079,7 @@ def CoreDumpArchiver(args):
|
|||
output_directory = next((arg[len(prefix):] for arg in args if arg.startswith(prefix)), None)
|
||||
|
||||
if not enabled:
|
||||
return NooptCoreDumpArchiver()
|
||||
return NooptContextManager()
|
||||
|
||||
osname = GuessOS()
|
||||
if osname == 'linux':
|
||||
|
@ -1082,8 +1093,16 @@ def CoreDumpArchiver(args):
|
|||
WindowsCoreDumpArchiver(output_directory))
|
||||
else:
|
||||
# We don't have support for MacOS yet.
|
||||
assert osname == 'macos'
|
||||
return NooptCoreDumpArchiver()
|
||||
return NooptContextManager()
|
||||
|
||||
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__":
|
||||
import sys
|
||||
|
|
Loading…
Reference in a new issue