Skip to content

Commit

Permalink
Fancier thread manipulation
Browse files Browse the repository at this point in the history
  • Loading branch information
bswck committed Oct 24, 2024
1 parent 420dfea commit 647314b
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions tests/unit_tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import threading
from collections import Counter
from itertools import product

import pytest

Expand Down Expand Up @@ -124,11 +125,8 @@ def access() -> None:
threading.Thread(target=access) for _ in range(num_threads)
]

for thread in threads:
thread.start()

for thread in threads:
thread.join()
for cb, thread in product((threading.Thread.start, threading.Thread.join), threads):
cb(thread)

assert sum(call_counts.values()) == 1

Expand Down Expand Up @@ -158,11 +156,8 @@ def access() -> None:
threading.Thread(target=access) for _ in range(num_threads)
]

for thread in threads:
thread.start()

for thread in threads:
thread.join()
for cb, thread in product((threading.Thread.start, threading.Thread.join), threads):
cb(thread)

assert set(call_counts.values()) == {1}

Expand Down

0 comments on commit 647314b

Please sign in to comment.