From 69e3f4598a8b1a4e3d20edcae524b05a8cc7f330 Mon Sep 17 00:00:00 2001 From: erick Date: Mon, 16 Nov 2009 04:13:18 +0000 Subject: Added a first implementation of a Future in dbustools, using the gtk mainloop for synchronisation --- (limited to 'tutorius/dbustools.py') diff --git a/tutorius/dbustools.py b/tutorius/dbustools.py index 5d70d7b..02acd3d 100644 --- a/tutorius/dbustools.py +++ b/tutorius/dbustools.py @@ -1,4 +1,6 @@ import logging +import gobject + LOGGER = logging.getLogger("sugar.tutorius.dbustools") def save_args(callable, *xargs, **xkwargs): @@ -40,3 +42,16 @@ def remote_call(callable, args, return_cb=None, error_cb=None, block=False): else: callable(*args, reply_handler=reply_cb, error_handler=errhandler_cb) +class Future(object): + def __init__(self): + self._value = None + + def get(self): + context = gobject.MainLoop().get_context() + while self._value == None and context.iteration(True): + pass + return self._value + + def _set(self, value): + self._value = value + -- cgit v0.9.1