def __getattr__(self, attr):
if not attr.startswith('async_'):
raise AttributeError
method_name = attr[6:]
if hasattr(self, method_name + '_buscallback'):
method = None
bus_callback = getattr(self, method_name + '_buscallback')
else:
method = getattr(self._agent.bus, method_name)
def bus_callback(method, callback, *args):
results = method(self._agent, *args)
self._agent.ioloop.add_callback(callback, results)
# dbus-specific - indicates this method should only be called
# once
return False
def _async(callback, *args):
self._agent.bus.busthread_call(bus_callback, method, callback,
*args)
return _async
评论列表
文章目录