Project

General

Profile

« Previous | Next » 

Revision 7eba70e1

Added by David Sorber almost 8 years ago

Add quasi async behavior example which I what I really need.

View differences:

software/dbus_test/service.py
#!/usr/bin/env python3
import time
import dbus
import dbus.service
import dbus.mainloop.glib
from gi.repository import GObject as gobject
from gi.repository import GLib
class Service(dbus.service.Object):
def __init__(self, message):
self._message = message
self.poke_ctr = 0
def run(self):
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
......
def get_message(self):
print(" sending message")
return self._message
@dbus.service.method("com.example.service.Poke", in_signature='', out_signature='')
def poke(self):
print('Got a poke!')
GLib.timeout_add(10, self.poke_runner)
print('Post idle add')
def poke_runner(self):
self.poke_ctr += 1
print(' Poke: {:d}'.format(self.poke_ctr))
time.sleep(3)
print(' Poke done')
return False
@dbus.service.method("com.example.service.Quit", in_signature='', out_signature='')
def quit(self):

Also available in: Unified diff