mirror of
https://github.com/esphome/esphome.git
synced 2025-08-06 18:37:47 +00:00
preen
This commit is contained in:
parent
49bc767bf4
commit
9188a8e326
@ -33,38 +33,39 @@ async def test_defer_stress(
|
|||||||
test_complete_future: asyncio.Future[None] = loop.create_future()
|
test_complete_future: asyncio.Future[None] = loop.create_future()
|
||||||
|
|
||||||
# Track executed defers and their order
|
# Track executed defers and their order
|
||||||
executed_defers = set()
|
executed_defers: set[int] = set()
|
||||||
thread_executions = {} # thread_id -> list of indices in execution order
|
thread_executions: dict[
|
||||||
fifo_violations = []
|
int, list[int]
|
||||||
|
] = {} # thread_id -> list of indices in execution order
|
||||||
|
fifo_violations: list[str] = []
|
||||||
|
|
||||||
def on_log_line(line: str) -> None:
|
def on_log_line(line: str) -> None:
|
||||||
# Track all executed defers with thread and index info
|
# Track all executed defers with thread and index info
|
||||||
match = re.search(r"Executed defer (\d+) \(thread (\d+), index (\d+)\)", line)
|
match = re.search(r"Executed defer (\d+) \(thread (\d+), index (\d+)\)", line)
|
||||||
if match:
|
if not match:
|
||||||
defer_id = int(match.group(1))
|
return
|
||||||
thread_id = int(match.group(2))
|
|
||||||
index = int(match.group(3))
|
|
||||||
|
|
||||||
executed_defers.add(defer_id)
|
defer_id = int(match.group(1))
|
||||||
|
thread_id = int(match.group(2))
|
||||||
|
index = int(match.group(3))
|
||||||
|
|
||||||
# Track execution order per thread
|
executed_defers.add(defer_id)
|
||||||
if thread_id not in thread_executions:
|
|
||||||
thread_executions[thread_id] = []
|
|
||||||
|
|
||||||
# Check FIFO ordering within thread
|
# Track execution order per thread
|
||||||
if (
|
if thread_id not in thread_executions:
|
||||||
thread_executions[thread_id]
|
thread_executions[thread_id] = []
|
||||||
and thread_executions[thread_id][-1] >= index
|
|
||||||
):
|
|
||||||
fifo_violations.append(
|
|
||||||
f"Thread {thread_id}: index {index} executed after {thread_executions[thread_id][-1]}"
|
|
||||||
)
|
|
||||||
|
|
||||||
thread_executions[thread_id].append(index)
|
# Check FIFO ordering within thread
|
||||||
|
if thread_executions[thread_id] and thread_executions[thread_id][-1] >= index:
|
||||||
|
fifo_violations.append(
|
||||||
|
f"Thread {thread_id}: index {index} executed after {thread_executions[thread_id][-1]}"
|
||||||
|
)
|
||||||
|
|
||||||
# Check if we've executed all 1000 defers (0-999)
|
thread_executions[thread_id].append(index)
|
||||||
if len(executed_defers) == 1000 and not test_complete_future.done():
|
|
||||||
test_complete_future.set_result(None)
|
# Check if we've executed all 1000 defers (0-999)
|
||||||
|
if len(executed_defers) == 1000 and not test_complete_future.done():
|
||||||
|
test_complete_future.set_result(None)
|
||||||
|
|
||||||
async with (
|
async with (
|
||||||
run_compiled(yaml_config, line_callback=on_log_line),
|
run_compiled(yaml_config, line_callback=on_log_line),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user