-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: normalized how exceptions are handled
- Loading branch information
Michael Kryukov
committed
Aug 8, 2023
1 parent
8d8e3b7
commit a7415b5
Showing
5 changed files
with
51 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import pytest | ||
|
||
from bounded_pool import ( | ||
BoundedAsyncioPoolExecutor, | ||
BoundedProcessPoolExecutor, | ||
BoundedThreadPoolExecutor, | ||
) | ||
|
||
|
||
def raiser(): | ||
raise ValueError() | ||
|
||
|
||
async def araiser(): | ||
raise ValueError() | ||
|
||
|
||
@pytest.mark.anyio | ||
async def test_asyncio_executor_ignores_exceptions(): | ||
async with BoundedAsyncioPoolExecutor() as pool: | ||
task = await pool.submit(araiser) | ||
|
||
with pytest.raises(ValueError): | ||
await task | ||
|
||
task = await pool.submit(araiser) | ||
|
||
with pytest.raises(ValueError): | ||
await task | ||
|
||
|
||
@pytest.mark.parametrize('cls', [BoundedThreadPoolExecutor, BoundedProcessPoolExecutor]) | ||
def test_sync_executor_ignores_exceptions(cls): | ||
with cls() as pool: | ||
task = pool.submit(raiser) | ||
|
||
with pytest.raises(ValueError): | ||
task.result() | ||
|
||
task = pool.submit(raiser) | ||
|
||
with pytest.raises(ValueError): | ||
task.result() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters