Skip to content

Commit

Permalink
Merge pull request #53 from python-thread/tests/thread-killing
Browse files Browse the repository at this point in the history
Test: Improving thread killing
  • Loading branch information
caffeine-addictt authored Mar 8, 2024
2 parents ab8ae94 + eb65675 commit 9dc7e1c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tests/test_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,22 @@ def test_ignoreAll():

def test_threadKilling():
"""This test is for testing that threads are killed properly"""
stdout = []

def _dummy_target_killThread(x: int, delay: float = 0):
for i in range(x):
stdout.append(i)
time.sleep(delay)

new = Thread(
target = _dummy_iterative,
args = [5, 0.1, 0]
target = _dummy_target_killThread,
args = [4, 1],
daemon = True
)
new.start()
new.kill(True)
assert not new.is_alive()
assert len(stdout) != 4



Expand Down

0 comments on commit 9dc7e1c

Please sign in to comment.