forked from aio-libs/aiopg
-
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 "Unable to detect disconnect when using NOTIFY/LISTEN", Closes ai…
- Loading branch information
Gustavo Carneiro
committed
Apr 9, 2019
1 parent
9fdf7b9
commit 72e34d5
Showing
4 changed files
with
95 additions
and
2 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,30 @@ | ||
import asyncio | ||
from aiopg.utils import ClosableQueue | ||
|
||
|
||
async def test_closable_queue_noclose(): | ||
queue = ClosableQueue() | ||
await queue.put(1) | ||
v = await queue.get() | ||
assert v == 1 | ||
|
||
|
||
async def test_closable_queue_close(loop): | ||
queue = ClosableQueue() | ||
v1 = None | ||
|
||
async def read(): | ||
nonlocal v1 | ||
v1 = await queue.get() | ||
await queue.get() | ||
|
||
reader = loop.create_task(read()) | ||
await queue.put(1) | ||
await asyncio.sleep(0.1) | ||
assert v1 == 1 | ||
|
||
queue.close(RuntimeError("connection closed")) | ||
try: | ||
await reader | ||
except RuntimeError as ex: | ||
assert ex.args == ("connection closed",) |