Skip to content
This repository was archived by the owner on Oct 1, 2021. It is now read-only.

Commit 8f3cee2

Browse files
committed
rpc: publish-subscribe: notify: make state optional
Signed-off-by: Florian Scherf <f.scherf@pengutronix.de>
1 parent ec356d1 commit 8f3cee2

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

aiohttp_json_rpc/rpc.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,12 +419,15 @@ def filter(self, topics):
419419
if len(topics & client.subscriptions) > 0:
420420
yield client
421421

422-
async def notify(self, topic, data=None):
422+
async def notify(self, topic, data=None, state=False):
423423
if type(topic) is not str:
424424
raise ValueError
425425

426-
self.state[topic] = data
426+
if state:
427+
self.state[topic] = data
428+
427429
notification = None
430+
428431
for client in self.filter(topic):
429432
try:
430433
if notification is None:

tests/test_publish_subscribe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ async def test_state(rpc_context):
7474

7575
# setup rpc
7676
rpc_context.rpc.add_topics('topic')
77-
await rpc_context.rpc.notify('topic', 'foo')
77+
await rpc_context.rpc.notify('topic', 'foo', state=True)
7878

7979
# setup client
8080
message = asyncio.Future()

0 commit comments

Comments
 (0)