Skip to content

Implement basis of terminate and without_terminate#1

Merged
kitsuyui merged 2 commits intomainfrom
basis
Jan 11, 2024
Merged

Implement basis of terminate and without_terminate#1
kitsuyui merged 2 commits intomainfrom
basis

Conversation

@kitsuyui
Copy link
Owner

@kitsuyui kitsuyui commented Jan 11, 2024

Usage

without_terminate

without_terminate is a generator that it will not yield after the timeout,
but it will not raise an exception.

from timeout_iterator import without_terminate
results = []
for i in without_terminate(range(10), seconds=0.3):
    results.append(i)
    time.sleep(0.1)

assert results == [0, 1, 2]

terminate

terminate is a generator that it will raise an exception after the timeout.

from timeout_iterator import terminate
try:
    results = []
    for i in terminate(range(10), seconds=0.3):
        results.append(i)
        time.sleep(0.1)
except TimeoutError:
    pass

assert results == [0, 1, 2]

@codecov-commenter
Copy link

Welcome to Codecov 🎉

Once merged to your default branch, Codecov will compare your coverage reports and display the results in this comment.

Thanks for integrating Codecov - We've got you covered ☂️

@kitsuyui kitsuyui merged commit 4c5bd5b into main Jan 11, 2024
@kitsuyui kitsuyui deleted the basis branch January 11, 2024 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants