Skip to content

Commit 90bc8ca

Browse files
Add test for running sync code within executor (#894)
1 parent 82ff150 commit 90bc8ca

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

tests/test_asyncio.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@ async def test_async_with_sync_passed_in_closed_in_async() -> None:
101101
await aiozc.async_close()
102102

103103

104+
@pytest.mark.asyncio
105+
async def test_sync_within_event_loop_executor() -> None:
106+
"""Test sync version still works from an executor within an event loop."""
107+
def sync_code():
108+
zc = Zeroconf(interfaces=['127.0.0.1'])
109+
assert zc.get_service_info("_neverused._tcp.local.", "xneverused._neverused._tcp.local.", 10) is None
110+
zc.close()
111+
112+
await asyncio.get_event_loop().run_in_executor(None, sync_code)
113+
114+
104115
@pytest.mark.asyncio
105116
async def test_async_service_registration() -> None:
106117
"""Test registering services broadcasts the registration by default."""

0 commit comments

Comments
 (0)