Add SubscriptionAPI

And `TrioSubscriptionAPI`, to make subscription io-agnostic.
This commit is contained in:
mhchia
2019-12-17 18:17:28 +08:00
parent fb0519129d
commit 47d10e186f
12 changed files with 158 additions and 36 deletions

View File

@ -27,7 +27,7 @@ async def test_simple_two_nodes():
await pubsubs_fsub[0].publish(topic, data)
res_b = await sub_b.receive()
res_b = await sub_b.get()
# Check that the msg received by node_b is the same
# as the message sent by node_a
@ -75,12 +75,9 @@ async def test_lru_cache_two_nodes(monkeypatch):
await trio.sleep(0.25)
for index in expected_received_indices:
res_b = await sub_b.receive()
res_b = await sub_b.get()
assert res_b.data == _make_testing_data(index)
with pytest.raises(trio.WouldBlock):
sub_b.receive_nowait()
@pytest.mark.parametrize("test_case_obj", floodsub_protocol_pytest_params)
@pytest.mark.trio