fix: handling of None messages from notify callback (#236)

Co-authored-by: Remy Noel <remy.noel@blade-group.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
Noel Remy 2023-09-07 17:55:12 +02:00 committed by GitHub
parent 8e17e91f0c
commit 14f52f216d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 3 deletions

View File

@ -1194,7 +1194,7 @@ class BaseMessageBus:
logging.error(
f'add match request failed. match="{self._name_owner_match_rule}", {err}'
)
if msg.message_type == MessageType.ERROR:
elif msg.message_type == MessageType.ERROR:
logging.error(
f'add match request failed. match="{self._name_owner_match_rule}", {msg.body[0]}'
)
@ -1228,7 +1228,7 @@ class BaseMessageBus:
def add_match_notify(msg: Message, err: Optional[Exception]) -> None:
if err:
logging.error(f'add match request failed. match="{match_rule}", {err}')
if msg.message_type == MessageType.ERROR:
elif msg.message_type == MessageType.ERROR:
logging.error(
f'add match request failed. match="{match_rule}", {msg.body[0]}'
)
@ -1267,7 +1267,7 @@ class BaseMessageBus:
logging.error(
f'remove match request failed. match="{match_rule}", {err}'
)
if msg.message_type == MessageType.ERROR:
elif msg.message_type == MessageType.ERROR:
logging.error(
f'remove match request failed. match="{match_rule}", {msg.body[0]}'
)

26
tests/client/test_aio.py Normal file
View File

@ -0,0 +1,26 @@
import pytest
from dbus_fast import aio
from dbus_fast.service import ServiceInterface
class ExampleInterface(ServiceInterface):
def __init__(self):
super().__init__("test.interface")
@pytest.mark.asyncio
async def test_fast_disconnect():
bus_name = "aio.client.test.methods"
bus = await aio.MessageBus().connect()
bus2 = await aio.MessageBus().connect()
await bus.request_name(bus_name)
service_interface = ExampleInterface()
bus.export("/test/path", service_interface)
introspection = await bus2.introspect(bus_name, "/test/path")
bus2.get_proxy_object(bus_name, "/test/path", introspection)
bus2.disconnect()
bus.disconnect()
await bus.wait_for_disconnect()
await bus2.wait_for_disconnect()

View File

@ -121,6 +121,8 @@ async def test_aio_proxy_object():
bus.disconnect()
bus2.disconnect()
await bus.wait_for_disconnect()
await bus2.wait_for_disconnect()
@pytest.mark.skipif(