Skip to content

Instantly share code, notes, and snippets.

@tu500
Created November 4, 2018 00:51
Show Gist options
  • Save tu500/3232fe03bd1d85b1529c558f920b8e43 to your computer and use it in GitHub Desktop.
Save tu500/3232fe03bd1d85b1529c558f920b8e43 to your computer and use it in GitHub Desktop.
DEBUG:asyncio:Using selector: EpollSelector
DEBUG:asyncio:poll 24996.047 ms took 0.013 ms: 1 events
DEBUG:asyncio:poll 24994.410 ms took 0.315 ms: 1 events
ERROR:asyncio:Task was destroyed but it is pending!
source_traceback: Object created at (most recent call last):
File "./client.py", line 75, in <module>
loop.run_until_complete(main())
File "/usr/lib64/python3.7/asyncio/base_events.py", line 560, in run_until_complete
self.run_forever()
File "/usr/lib64/python3.7/asyncio/base_events.py", line 528, in run_forever
self._run_once()
File "/usr/lib64/python3.7/asyncio/base_events.py", line 1756, in _run_once
handle._run()
File "/usr/lib64/python3.7/asyncio/events.py", line 88, in _run
self._context.run(self._callback, *self._args)
File "/home/tu500/.local/lib/python3.7/site-packages/dbussy.py", line 1759, in call_dispatch
status = dispatch()
File "/home/tu500/.local/lib/python3.7/site-packages/dbussy.py", line 2278, in dispatch
dbus.dbus_connection_dispatch(self._dbobj)
File "/home/tu500/.local/lib/python3.7/site-packages/dbussy.py", line 2506, in wrap_function
result = function(self, Message(dbus.dbus_message_ref(message)), user_data)
File "/home/tu500/.local/lib/python3.7/site-packages/ravel.py", line 2347, in _message_interface_dispatch
bus.loop.create_task(result)
task: <Task pending coro=<LevelA.on_new_levelB() done, defined at ./client.py:56> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7fa68792f168>()] created at /usr/lib64/python3.7/asyncio/base_events.py:385> created at /home/tu500/.local/lib/python3.7/site-packages/ravel.py:2347>
ERROR:asyncio:Task was destroyed but it is pending!
source_traceback: Object created at (most recent call last):
File "./client.py", line 75, in <module>
loop.run_until_complete(main())
File "/usr/lib64/python3.7/asyncio/base_events.py", line 560, in run_until_complete
self.run_forever()
File "/usr/lib64/python3.7/asyncio/base_events.py", line 528, in run_forever
self._run_once()
File "/usr/lib64/python3.7/asyncio/base_events.py", line 1756, in _run_once
handle._run()
File "/usr/lib64/python3.7/asyncio/events.py", line 88, in _run
self._context.run(self._callback, *self._args)
File "/home/tu500/.local/lib/python3.7/site-packages/dbussy.py", line 1780, in handle_watch_event
call_dispatch()
File "/home/tu500/.local/lib/python3.7/site-packages/dbussy.py", line 1759, in call_dispatch
status = dispatch()
File "/home/tu500/.local/lib/python3.7/site-packages/dbussy.py", line 2278, in dispatch
dbus.dbus_connection_dispatch(self._dbobj)
File "/home/tu500/.local/lib/python3.7/site-packages/dbussy.py", line 2506, in wrap_function
result = function(self, Message(dbus.dbus_message_ref(message)), user_data)
File "/home/tu500/.local/lib/python3.7/site-packages/ravel.py", line 2347, in _message_interface_dispatch
bus.loop.create_task(result)
task: <Task pending coro=<LevelA.on_new_levelB() done, defined at ./client.py:56> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7fa68792f6d8>()] created at /usr/lib64/python3.7/asyncio/base_events.py:385> created at /home/tu500/.local/lib/python3.7/site-packages/ravel.py:2347>
dbus[28503]: arguments to dbus_pending_call_steal_reply() were incorrect, assertion "pending->completed" failed in file ../../dbus/dbus-pending-call.c line 733.
This is normally a bug in some application using the D-Bus library.
D-Bus not built with -rdynamic so unable to print a backtrace
#!/usr/bin/python3
import asyncio
import ravel
import dbussy
class ClientInterface(dbussy.Introspection.Interface):
def __init__(self):
dbussy.Introspection.Interface.__init__(self, self._interface_name)
def dbus_register(self, path, bus=None):
if bus is None:
bus = ravel.session_bus()
self._dbus_bus = bus
self._dbus_path = path
bus.register(path=path, fallback=False, interface=self)
def dbus_unregister(self):
self._dbus_bus.unregister(path=self._dbus_path, interface=None)
@ravel.interface(ravel.INTERFACE.CLIENT, name='com.example.levelB')
class LevelB(ClientInterface):
def __init__(self, path):
self.path = path
self.jobs = []
async def init(self):
self.dbus_register(self.path)
self.proxy = await self._dbus_bus['com.example.foobar'][self.path] \
.get_async_interface(self._interface_name)
@ravel.interface(ravel.INTERFACE.CLIENT, name='com.example.levelA')
class LevelA(ClientInterface):
def __init__(self, path):
self.path = path
self.levelBs = []
async def init(self):
self.dbus_register(self.path)
self.proxy = await self._dbus_bus['com.example.foobar'][self.path] \
.get_async_interface(self._interface_name)
async def start_first_stage(self):
await self.proxy.start_first_stage()
async def get_levelBs(self):
l, = await self.proxy.get_levelBs()
self.levelBs = [LevelB(p) for p in l]
for j in self.levelBs:
await j.init()
@ravel.signal(in_signature='o')
async def on_new_levelB(self, path):
j = LevelB(path)
await j.init()
self.levelBs.append(j)
async def main():
levelA = LevelA('/levelA')
await levelA.init()
await levelA.start_first_stage()
await asyncio.sleep(10)
import logging
logging.basicConfig(level=logging.DEBUG)
loop = asyncio.get_event_loop()
loop.set_debug(True)
ravel.session_bus().attach_asyncio(loop)
loop.run_until_complete(main())
#!/usr/bin/python3
import asyncio
import dbussy
import ravel
import logging
from dbussy import DBUS
logging.getLogger().setLevel(logging.INFO)
class DBusObject():
def dbus_register(self, path, bus=None):
if bus is None:
bus = ravel.session_bus()
self._dbus_bus = bus
self._dbus_path = path
bus.register(path=path, fallback=False, interface=self)
def dbus_unregister(self):
self._dbus_bus.unregister(path=self._dbus_path, interface=None)
def dbus_send_signal(self, name, *args):
self._dbus_bus.send_signal(
path=self._dbus_path,
interface=self._interface_name,
name=name,
args=args,
)
@ravel.interface(ravel.INTERFACE.SERVER, name='com.example.levelB')
class LevelB(DBusObject):
def __init__(self, index, levelA):
self.index = index
self.path = levelA.path + '/p{}'.format(self.index)
def init(self):
self.dbus_register(self.path)
@ravel.interface(ravel.INTERFACE.SERVER, name='com.example.levelA')
class LevelA(DBusObject):
def __init__(self):
self.levelBs = []
self.path = '/levelA'
async def first_stage(self):
self.levelBs = [LevelB(i, self) for i in range(5)]
for b in self.levelBs:
b.init()
self.dbus_send_signal('on_new_levelB', b.path)
print('new levelB', b.path)
@ravel.method(
in_signature='',
out_signature='',
)
def start_first_stage(self):
asyncio.create_task(self.first_stage())
@ravel.signal(in_signature='o')
def on_new_levelB(self): ...
def init(self):
self.dbus_register(self.path)
print('Starting server')
loop = asyncio.get_event_loop()
bus = ravel.session_bus()
bus.attach_asyncio(loop)
bus.request_name(bus_name='com.example.foobar', flags=DBUS.NAME_FLAG_DO_NOT_QUEUE)
levelA = LevelA()
levelA.init()
loop.run_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment