Author: dmeyer
Date: Sun Apr 23 11:21:06 2006
New Revision: 1485
Modified:
trunk/beacon/src/directory.py
trunk/beacon/src/monitor.py
Log:
add some debug
Modified: trunk/beacon/src/directory.py
==============================================================================
--- trunk/beacon/src/directory.py (original)
+++ trunk/beacon/src/directory.py Sun Apr 23 11:21:06 2006
@@ -147,6 +147,12 @@
for is_overlay, prefix, results in ((False, self.filename,
fs_results),
(True, self._beacon_ovdir,
overlay_results)):
for r in results:
+ # FIXME: for some large directories not in the hd cache this
+ # can take a long time. E.g. /usr/bin takes 3 seconds in this
+ # part. Once done, a second check is much faster (0.3 sec).
+ # It would be nice if we can do a stat on demand, but we need
+ # to know if an item is a dir or file, so we will always need
+ # this. Maybe step() from time to time?
if (is_overlay and r in results_file_map) or r[0] == ".":
continue
fullpath = prefix + r
@@ -154,7 +160,7 @@
# append stat information to every result
statinfo = os.stat(fullpath)
if is_overlay and stat.S_ISDIR(statinfo[stat.ST_MODE]):
- # overlay dir, remove
+ # dir in overlay, ignore
log.warning('skip overlay dir %s' % r[1])
continue
except (OSError, IOError), e:
Modified: trunk/beacon/src/monitor.py
==============================================================================
--- trunk/beacon/src/monitor.py (original)
+++ trunk/beacon/src/monitor.py Sun Apr 23 11:21:06 2006
@@ -55,21 +55,38 @@
class Master(object):
+ """
+ Master Monitor. This monitor will connect to the db and will call all
monitors
+ with the changes. This class will make sure they don't re-query all at once
+ and have a small delay between them to keep the load down.
+ """
def __init__(self, db):
self.monitors = []
self.timer = Timer(self.check)
db.signals['changed'].connect(self.changed)
+
def connect(self, monitor):
+ """
+ Connect a new monitor.
+ """
self.monitors.append((weakref(monitor), []))
+
def changed(self, changes):
+ """
+ Database callback with changed ids.
+ """
for m, c in self.monitors:
c.extend(changes)
if not self.timer.active():
self.timer.start(0.02)
+
def check(self):
+ """
+ Timed callback to call the connected monitor update functions.
+ """
if not self.monitors:
return False
monitor, changes = self.monitors.pop(0)
@@ -139,7 +156,11 @@
# Same length, check for changes inside the items
if isinstance(current[0], Item):
for i in current:
- if i._beacon_id in changes:
+ # We only compare the ids. If an item had no id before and
+ # has now we can't detect it. But we only call this function
+ # if we have a full scanned db. So an empty id also triggers
+ # the update call.
+ if i._beacon_id in changes or not i._beacon_id:
self.items = current
self.callback('changed')
return True
@@ -205,6 +226,9 @@
def checked(self, first_call):
+ """
+ Callback from the Checker class in parser when everything is parsed.
+ """
self._checker = None
# The client will update its query on this signal, so it should
# be safe to do the same here. *cross*fingers*
@@ -220,6 +244,9 @@
def stop(self):
+ """
+ Stop checking.
+ """
if self._checker:
self._checker.stop()
self._checker = None
@@ -227,7 +254,3 @@
def __repr__(self):
return '<beacon.Monitor for %s>' % self._query
-
-
- def __del__(self):
- log.debug('del %s' % repr(self))
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog