replace deprecated asyncio.get_event_loop()
`asyncio.get_event_loop()` was deprecated in Python 3.10, so we should use `asyncio.get_running_loop()` instead.
This commit is contained in:
parent
c0671be366
commit
691ff8e1bf
@ -78,7 +78,7 @@ from dbus_fast.aio import MessageBus
|
||||
|
||||
import asyncio
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
loop = asyncio.get_running_loop()
|
||||
|
||||
|
||||
async def main():
|
||||
@ -159,9 +159,9 @@ async def main():
|
||||
# now that we are ready to handle requests, we can request name from D-Bus
|
||||
await bus.request_name('test.name')
|
||||
# wait indefinitely
|
||||
await asyncio.get_event_loop().create_future()
|
||||
await asyncio.get_running_loop().create_future()
|
||||
|
||||
asyncio.get_event_loop().run_until_complete(main())
|
||||
asyncio.get_running_loop().run_until_complete(main())
|
||||
```
|
||||
|
||||
## The Low-Level Interface
|
||||
@ -177,7 +177,7 @@ from dbus_fast.aio import MessageBus
|
||||
import asyncio
|
||||
import json
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
loop = asyncio.get_running_loop()
|
||||
|
||||
|
||||
async def main():
|
||||
|
||||
@ -90,4 +90,4 @@ If any file descriptors are sent or received (DBus type ``h``), the variable ref
|
||||
|
||||
await bus.wait_for_disconnect()
|
||||
|
||||
asyncio.get_event_loop().run_until_complete(main())
|
||||
asyncio.get_running_loop().run_until_complete(main())
|
||||
|
||||
@ -10,7 +10,7 @@ import json
|
||||
from dbus_fast import Message, MessageType
|
||||
from dbus_fast.aio import MessageBus
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
loop = asyncio.get_running_loop()
|
||||
|
||||
|
||||
async def main():
|
||||
|
||||
@ -17,7 +17,7 @@ import asyncio
|
||||
|
||||
from dbus_fast.aio import MessageBus
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
loop = asyncio.get_running_loop()
|
||||
|
||||
|
||||
async def main():
|
||||
|
||||
@ -101,7 +101,7 @@ else:
|
||||
if not signature:
|
||||
exit_error("--signature is a required argument when passing a message body")
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
loop = asyncio.get_running_loop()
|
||||
|
||||
|
||||
async def main():
|
||||
|
||||
@ -64,4 +64,4 @@ async def main():
|
||||
await bus.wait_for_disconnect()
|
||||
|
||||
|
||||
asyncio.get_event_loop().run_until_complete(main())
|
||||
asyncio.get_running_loop().run_until_complete(main())
|
||||
|
||||
@ -8,7 +8,7 @@ import asyncio
|
||||
|
||||
from dbus_fast.aio import MessageBus
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
loop = asyncio.get_running_loop()
|
||||
|
||||
|
||||
async def main():
|
||||
|
||||
@ -161,7 +161,7 @@ class MessageBus(BaseMessageBus):
|
||||
):
|
||||
super().__init__(bus_address, bus_type, ProxyObject)
|
||||
self._negotiate_unix_fd = negotiate_unix_fd
|
||||
self._loop = asyncio.get_event_loop()
|
||||
self._loop = asyncio.get_running_loop()
|
||||
self._unmarshaller = self._create_unmarshaller()
|
||||
|
||||
self._writer = _MessageWriter(self)
|
||||
|
||||
@ -270,7 +270,7 @@ async def test_property_changed_signal(interface_class):
|
||||
|
||||
async def wait_for_message():
|
||||
# TODO timeout
|
||||
future = asyncio.get_event_loop().create_future()
|
||||
future = asyncio.get_running_loop().create_future()
|
||||
|
||||
def message_handler(signal):
|
||||
if signal.interface == "org.freedesktop.DBus.Properties":
|
||||
|
||||
@ -60,7 +60,7 @@ class SecondExampleInterface(ServiceInterface):
|
||||
|
||||
class ExpectMessage:
|
||||
def __init__(self, bus1, bus2, interface_name, timeout=1):
|
||||
self.future = asyncio.get_event_loop().create_future()
|
||||
self.future = asyncio.get_running_loop().create_future()
|
||||
self.bus1 = bus1
|
||||
self.bus2 = bus2
|
||||
self.interface_name = interface_name
|
||||
@ -78,7 +78,7 @@ class ExpectMessage:
|
||||
|
||||
async def __aenter__(self):
|
||||
self.bus2.add_message_handler(self.message_handler)
|
||||
self.timeout_task = asyncio.get_event_loop().call_later(
|
||||
self.timeout_task = asyncio.get_running_loop().call_later(
|
||||
self.timeout, self.timeout_cb
|
||||
)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user