On Sat, 2007-07-28 at 11:53 +0200, Marco Pesenti Gritti wrote:
> * The shell service needs to be in a separate process/thread than the
> UI one, to avoid performance issues and dead locks. Tomeu is already
> working on it, I want to get it in as soon as possible.
Looks like dbus-python doesn't support yet multiple main loops. Simon,
is this right? When can we expect to get this?
Attached is the script I'm using to test this.
Tomeu
#!/usr/bin/env python
import sys
import random
import time
import dbus
import dbus.service
import dbus.mainloop.glib
import gobject
if sys.argv[1] == 'client':
global obj
bus = dbus.SessionBus()
obj = bus.get_object('test.Test', '/test/Test')
def timer_cb():
t = time.time()
obj.print_mec(dbus_interface='test.Test')
print 'Remote call print_mec lasted %fs.' % (time.time() - t)
return True
loop = gobject.MainLoop()
gobject.idle_add(timer_cb)
loop.run()
elif sys.argv[1] == 'service':
global service
service = None
class TestService(dbus.service.Object):
@dbus.service.method('test.Test', in_signature='', out_signature='')
def print_mec(self):
print 'mec'
def launch_service():
loop = dbus.mainloop.glib.DBusGMainLoop()
bus = dbus.SessionBus(private=True, mainloop=loop)
bus_name = dbus.service.BusName('test.Test', bus=bus)
global service
service = TestService(bus_name, '/test/Test')
def timer_cb():
seconds = 2 + random.random() * 2
print '\nGoing to sleep for %fs.' % seconds
time.sleep(seconds)
print 'Finished sleep of %fs.' % seconds
return True
from threading import Thread
thread = Thread(target=launch_service, args=[], name='TestThread')
thread.start()
loop = gobject.MainLoop()
gobject.idle_add(timer_cb)
loop.run()
_______________________________________________
Sugar mailing list
[email protected]
http://lists.laptop.org/listinfo/sugar