Skip to content

Commit ba2a023

Browse files
James Sunfacebook-github-bot
authored andcommitted
fix test_flush_logs_fast_exit (#841)
Summary: Pull Request resolved: #841 we got error "OS can't spawn worker thread: Resource temporarily unavailable (os error 11)" under sandcastle stress test. There is no need to manually create another 20 processes, which will cause 400 processes spawned. Just use one pass to test and leave the rest to sandcastle. Reviewed By: mariusae Differential Revision: D80149544 fbshipit-source-id: d244b4739121f5199273957df6c5f7370a2f88a9
1 parent fb6bdc5 commit ba2a023

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

python/tests/python_actor_test_binary.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ async def _flush_logs() -> None:
4040
for _ in range(5):
4141
await am.print.call("has print streaming")
4242

43-
await pm.stop()
43+
# TODO: will soon be removed by D80051803
44+
await asyncio.sleep(2)
4445

4546

4647
@main.command("flush-logs")

python/tests/test_python_actors.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -727,25 +727,23 @@ async def test_flush_logs_fast_exit() -> None:
727727
# Run the binary in a separate process and capture stdout and stderr
728728
cmd = [str(test_bin), "flush-logs"]
729729

730-
# Stress test
731-
for _ in range(20):
732-
process = subprocess.run(cmd, capture_output=True, timeout=60, text=True)
733-
734-
# Check if the process ended without error
735-
if process.returncode != 0:
736-
raise RuntimeError(f"{cmd} ended with error code {process.returncode}. ")
737-
738-
# Assertions on the captured output, 160 = 32 procs * 5 logs per proc
739-
# 32 and 5 are specified in the test_bin flush-logs.
740-
assert (
741-
len(
742-
re.findall(
743-
r"160 similar log lines.*has print streaming",
744-
process.stdout,
745-
)
730+
process = subprocess.run(cmd, capture_output=True, timeout=60, text=True)
731+
732+
# Check if the process ended without error
733+
if process.returncode != 0:
734+
raise RuntimeError(f"{cmd} ended with error code {process.returncode}. ")
735+
736+
# Assertions on the captured output, 160 = 32 procs * 5 logs per proc
737+
# 32 and 5 are specified in the test_bin flush-logs.
738+
assert (
739+
len(
740+
re.findall(
741+
r"160 similar log lines.*has print streaming",
742+
process.stdout,
746743
)
747-
== 1
748-
), process.stdout
744+
)
745+
== 1
746+
), process.stdout
749747

750748

751749
@pytest.mark.timeout(60)

0 commit comments

Comments
 (0)