Author: dmeyer
Date: Thu Jun 28 19:03:07 2007
New Revision: 2744
Modified:
trunk/WIP/beacon2/src/db.py
trunk/WIP/beacon2/src/server/crawl.py
Log:
the server can deal with async queries now
Modified: trunk/WIP/beacon2/src/db.py
==============================================================================
--- trunk/WIP/beacon2/src/db.py (original)
+++ trunk/WIP/beacon2/src/db.py Thu Jun 28 19:03:07 2007
@@ -209,7 +209,7 @@
else:
dirname = parent.filename[:-1]
- listing = parent._beacon_listdir(async=self.client)
+ listing = parent._beacon_listdir(async=True)
if isinstance(listing, kaa.notifier.InProgress):
# oops, something takes more time than we had in mind,
@@ -299,10 +299,7 @@
else:
dirname = parent.filename[:-1]
- async = False
- if self.client:
- async = True
- timer = time.time()
+ timer = time.time()
items = []
# A list of all directories we will look at. If a link is in the
@@ -319,7 +316,7 @@
directories.append(child)
else:
items.append(create_file(i, parent, isdir=False))
- if async and time.time() > timer + 0.1:
+ if time.time() > timer + 0.1:
# we are in async mode and already use too much time.
# call yield YieldContinue at this point to continue
# later.
@@ -357,19 +354,6 @@
return create_file(basename, parent, isdir=os.path.isdir(filename))
- @kaa.notifier.yield_execution()
- def _db_query_dirname(self, dirname, **query):
- """
- Return items in a directory
- """
- dobject = self._db_query_filename(dirname)
- if isinstance(dobject, kaa.notifier.InProgress):
- yield dobject
- dobject = dobject()
- query['parent'] = dobject
- yield self.query(**query)
-
-
def _db_query_id(self, (type, id), cache=None):
"""
Return item based on (type,id). Use given cache if provided.
Modified: trunk/WIP/beacon2/src/server/crawl.py
==============================================================================
--- trunk/WIP/beacon2/src/server/crawl.py (original)
+++ trunk/WIP/beacon2/src/server/crawl.py Thu Jun 28 19:03:07 2007
@@ -188,7 +188,7 @@
# a timer is already active and we can return. It still uses too
# much CPU time in the burst, but there is nothing we can do about
# it.
- return True
+ yield True
# some debugging to find a bug in beacon
log.info('inotify: event %s for "%s"', mask, name)
@@ -200,7 +200,7 @@
if not item._beacon_parent.filename in self.monitoring:
# that is a different monitor, ignore it
# FIXME: this is a bug (missing feature) in inotify
- return True
+ yield True
if item._beacon_name.startswith('.'):
# hidden file, ignore except in move operations
@@ -209,7 +209,7 @@
# this as a create for the new one.
log.info('inotify: handle move as create for %s', args[0])
self._inotify_event(INotify.CREATE, args[0])
- return True
+ yield True
# ---------------------------------------------------------------------
# MOVE_FROM -> MOVE_TO
@@ -225,7 +225,7 @@
# move to hidden file, delete
log.info('inotify: move to hidden file, delete')
self._inotify_event(INotify.DELETE, name)
- return True
+ yield True
if move._beacon_id:
# New item already in the db, delete it first
log.info('inotify delete: %s', item)
@@ -251,7 +251,7 @@
self._scan_add(move._beacon_parent, recursive=False)
if not mask & INotify.ISDIR:
- return True
+ yield True
# The directory is a dir. We now remove all the monitors to that
# directory and crawl it again. This keeps track for softlinks that
@@ -259,7 +259,7 @@
self.monitoring.remove(name + '/', recursive=True)
# now make sure the directory is parsed recursive again
self._scan_add(move, recursive=True)
- return True
+ yield True
# ---------------------------------------------------------------------
# MOVE_TO, CREATE, MODIFY or CLOSE_WRITE
@@ -280,7 +280,7 @@
if name.lower().endswith('/video_ts'):
# it could be a dvd on hd
self._scan_add(item._beacon_parent, recursive=False)
- return True
+ yield True
# handle bursts of inotify events when a file is growing very
# fast (e.g. cp)
@@ -291,7 +291,7 @@
# item another item may be affected (xml metadata, images)
# so scan the file by rechecking the parent dir
self._scan_add(item._beacon_parent, recursive=False)
- return True
+ yield True
# ---------------------------------------------------------------------
# DELETE
@@ -305,7 +305,7 @@
# shutdown, so we just ignore this event for now.
if name + '/' in self.monitoring:
self.monitoring.remove(name + '/', recursive=True)
- return True
+ yield True
# The file does not exist, we need to delete it in the database
if self.db.get_object(item._beacon_data['name'],
@@ -323,7 +323,7 @@
self.monitoring.remove(name + '/', recursive=True)
# rescan parent directory
self._scan_add(item._beacon_parent, recursive=False)
- return True
+ yield True
# -------------------------------------------------------------------------
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog