zeitgeist team mailing list archive
-
zeitgeist team
-
Mailing list archive
-
Message #03174
[Merge] lp:~seif/zeitgeist/fix-738555 into lp:zeitgeist
Seif Lotfy has proposed merging lp:~seif/zeitgeist/fix-738555 into lp:zeitgeist.
Requested reviews:
Zeitgeist Framework Team (zeitgeist)
Related bugs:
Bug #738555 in Zeitgeist Framework: "zeitgeist-daemon crashed with IOError in _write_to_disk(): [Errno 2] No such file or directory: '/home/royg/.local/share/zeitgeist/datasources.pickle'"
https://bugs.launchpad.net/zeitgeist/+bug/738555
For more details, see:
https://code.launchpad.net/~seif/zeitgeist/fix-738555/+merge/58818
Add a try except block in the _write_to_disk method
Add a counter to write to disk upon every 20 events
Fixed some indents
--
https://code.launchpad.net/~seif/zeitgeist/fix-738555/+merge/58818
Your team Zeitgeist Framework Team is requested to review the proposed merge of lp:~seif/zeitgeist/fix-738555 into lp:zeitgeist.
=== modified file '_zeitgeist/engine/extensions/datasource_registry.py'
--- _zeitgeist/engine/extensions/datasource_registry.py 2011-01-17 15:54:47 +0000
+++ _zeitgeist/engine/extensions/datasource_registry.py 2011-04-22 14:13:34 +0000
@@ -88,16 +88,23 @@
# Connect to client disconnection signals
dbus.SessionBus().add_signal_receiver(self._name_owner_changed,
- signal_name="NameOwnerChanged",
- dbus_interface=dbus.BUS_DAEMON_IFACE,
- arg2="", # only match services with no new owner
- )
+ signal_name="NameOwnerChanged",
+ dbus_interface=dbus.BUS_DAEMON_IFACE,
+ arg2="", # only match services with no new owner
+ )
+
+ # The counter is to keep track of how many events were inserted and then
+ # write the register to disk when N is reached
+ self._counter = 0
def _write_to_disk(self):
data = [DataSource.get_plain(datasource) for datasource in
self._registry.itervalues()]
- with open(DATA_FILE, "w") as data_file:
- pickle.dump(data, data_file)
+ try:
+ with open(DATA_FILE, "w") as data_file:
+ pickle.dump(data, data_file)
+ except Exception, e:
+ log.warn("Failed to write to data file %s: %s" % (DATA_FILE, e))
#log.debug("Data-source registry update written to disk.")
def pre_insert_event(self, event, sender):
@@ -109,6 +116,12 @@
# Check whether the data-source is allowed to insert events
if not datasource.enabled:
return None
+ self._counter += 1
+
+ # Write to disk every 20 events
+ if self._counter%20 == 0:
+ self._write_to_disk()
+
return event
def unload(self):
Follow ups