Add timeout arg to sugar.datastore.Datastore.

This commit is contained in:
Tomeu Vizoso 2007-07-26 09:20:38 +02:00
parent ee68ed1fb9
commit 20d5eaf4bc
3 changed files with 7 additions and 4 deletions

1
NEWS
View File

@ -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 * 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 by adding environment variables like SHELL_DEBUG and RECORD_DEBUG to
the sugar environment the sugar environment

View File

@ -172,7 +172,7 @@ def create():
metadata['mtime'] = metadata['ctime'] metadata['mtime'] = metadata['ctime']
return DSObject(object_id=None, metadata=metadata, file_path=None) 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') logging.debug('datastore.write')
properties = ds_object.metadata.get_dictionary().copy() 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, properties,
ds_object.file_path, ds_object.file_path,
reply_handler=reply_handler, reply_handler=reply_handler,
error_handler=error_handler) error_handler=error_handler,
timeout=timeout)
else: else:
ds_object.object_id = dbus_helpers.create(properties, ds_object.object_id = dbus_helpers.create(properties,
ds_object.file_path) ds_object.file_path)

View File

@ -37,12 +37,13 @@ def create(properties, filename):
logging.debug('dbus_helpers.create: ' + object_id) logging.debug('dbus_helpers.create: ' + object_id)
return 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)) logging.debug('dbus_helpers.update: %s, %s, %s' % (uid, filename, properties))
if reply_handler and error_handler: if reply_handler and error_handler:
_data_store.update(uid, dbus.Dictionary(properties), filename, _data_store.update(uid, dbus.Dictionary(properties), filename,
reply_handler=reply_handler, reply_handler=reply_handler,
error_handler=error_handler) error_handler=error_handler,
timeout=timeout)
else: else:
_data_store.update(uid, dbus.Dictionary(properties), filename) _data_store.update(uid, dbus.Dictionary(properties), filename)