diff --git a/NEWS b/NEWS index 72afe0ff..82b42983 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,4 @@ +* Add timeout arg to sugar.datastore.Datastore. (tomeu) * Turn off logging by default. Logs may be re-enabled on a per-module basis by adding environment variables like SHELL_DEBUG and RECORD_DEBUG to the sugar environment diff --git a/sugar/datastore/datastore.py b/sugar/datastore/datastore.py index ef1dd45a..256c12fa 100644 --- a/sugar/datastore/datastore.py +++ b/sugar/datastore/datastore.py @@ -172,7 +172,7 @@ def create(): metadata['mtime'] = metadata['ctime'] return DSObject(object_id=None, metadata=metadata, file_path=None) -def write(ds_object, update_mtime=True, reply_handler=None, error_handler=None): +def write(ds_object, update_mtime=True, reply_handler=None, error_handler=None, timeout=-1): logging.debug('datastore.write') properties = ds_object.metadata.get_dictionary().copy() @@ -185,7 +185,8 @@ def write(ds_object, update_mtime=True, reply_handler=None, error_handler=None): properties, ds_object.file_path, reply_handler=reply_handler, - error_handler=error_handler) + error_handler=error_handler, + timeout=timeout) else: ds_object.object_id = dbus_helpers.create(properties, ds_object.file_path) diff --git a/sugar/datastore/dbus_helpers.py b/sugar/datastore/dbus_helpers.py index 6680cc12..f0cfa3bf 100644 --- a/sugar/datastore/dbus_helpers.py +++ b/sugar/datastore/dbus_helpers.py @@ -37,12 +37,13 @@ def create(properties, filename): logging.debug('dbus_helpers.create: ' + object_id) return object_id -def update(uid, properties, filename, reply_handler=None, error_handler=None): +def update(uid, properties, filename, reply_handler=None, error_handler=None, timeout=-1): logging.debug('dbus_helpers.update: %s, %s, %s' % (uid, filename, properties)) if reply_handler and error_handler: _data_store.update(uid, dbus.Dictionary(properties), filename, reply_handler=reply_handler, - error_handler=error_handler) + error_handler=error_handler, + timeout=timeout) else: _data_store.update(uid, dbus.Dictionary(properties), filename)