Author: tack
Date: Fri Jun 29 22:18:40 2007
New Revision: 2752

Modified:
   trunk/WIP/beacon2/bin/beacon
   trunk/WIP/beacon2/src/client.py
   trunk/WIP/beacon2/src/db.py
   trunk/WIP/beacon2/src/query.py
   trunk/WIP/beacon2/src/server/db.py

Log:
Increase MAX_BUFFER_CHANGES to 200; Query now always emits 'changed' if query
is async; fix beacon tool to handle async queries; add FIXME to
_db_query_raw because it's slow as hell.


Modified: trunk/WIP/beacon2/bin/beacon
==============================================================================
--- trunk/WIP/beacon2/bin/beacon        (original)
+++ trunk/WIP/beacon2/bin/beacon        Fri Jun 29 22:18:40 2007
@@ -324,16 +324,23 @@
         sys.exit(0)
 
 
-    if not monitor or result.valid:
-        t2 = time.time()
-        print_results(result)
-        print 'Query took %s seconds; %d results' % ((t2-t1), len(result))
-        if not monitor:
+    if not monitor:
+        def print_results_and_exit(result):
+            t2 = time.time()
+            print_results(result)
+            print 'Query took %s seconds; %d results' % ((t2-t1), len(result))
             sys.exit(0)
-    result.signals['changed'].connect(changed, result)
-    result.signals['progress'].connect(progress)
-    result.signals['up-to-date'].connect(uptodate)
-    result.monitor()
+        if not result.valid:
+            # Query is pending, connect to changed signal to display results.
+            result.signals['changed'].connect_once(print_results_and_exit, 
result)
+        else:
+            print_results_and_exit(result)
+    else:
+        result.signals['changed'].connect(changed, result)
+        result.signals['progress'].connect(progress)
+        result.signals['up-to-date'].connect(uptodate)
+        result.monitor()
+
     kaa.notifier.loop()
     sys.exit(0)
 

Modified: trunk/WIP/beacon2/src/client.py
==============================================================================
--- trunk/WIP/beacon2/src/client.py     (original)
+++ trunk/WIP/beacon2/src/client.py     Fri Jun 29 22:18:40 2007
@@ -277,7 +277,11 @@
         self.rpc('db.lock')
         result = self._db.query(**kwargs)
         if isinstance(result, kaa.notifier.InProgress):
-            result.connect(self.rpc, 'db.unlock')
+            cb = kaa.notifier.Callback(self.rpc, 'db.unlock')
+            # Call args will be the result set of the query.  We don't want to
+            # send this over RPC.
+            cb.set_ignore_caller_args()
+            result.connect(cb)
         else:
             self.rpc('db.unlock')
         return result

Modified: trunk/WIP/beacon2/src/db.py
==============================================================================
--- trunk/WIP/beacon2/src/db.py (original)
+++ trunk/WIP/beacon2/src/db.py Fri Jun 29 22:18:40 2007
@@ -355,6 +355,8 @@
         parent structure. For files / directories this function won't check
         if they are still there.
         """
+        # FIXME: this function needs optimizing; adds at least 6 times the
+        # overhead on top of kaa.db.query
         result = []
         cache = {}
         counter = 0

Modified: trunk/WIP/beacon2/src/query.py
==============================================================================
--- trunk/WIP/beacon2/src/query.py      (original)
+++ trunk/WIP/beacon2/src/query.py      Fri Jun 29 22:18:40 2007
@@ -74,6 +74,7 @@
         self._query = query
         self._client = client
         self.monitoring = False
+        # XXX: maybe 'completed' is better than 'valid'?
         self.valid = False
         self.result = []
         self._beacon_start_query(query, False)
@@ -165,6 +166,9 @@
             wait = kaa.notifier.YieldCallback()
             self._client.signals['connect'].connect_once(wait)
             yield wait
+            emit_signal = True
+            # Since query was async, we need to emit 'changed' signal, so
+            # override emit_signal argument.
 
         if 'parent' in query and isinstance(query['parent'], Item) and \
                not query['parent']._beacon_id:
@@ -175,10 +179,16 @@
             log.info('force data for %s', parent)
             parent._beacon_request(self._beacon_start_query, query, True)
             return
+
         self.result = self._client._beacon_query(**query)
+
         if isinstance(self.result, kaa.notifier.InProgress):
             yield self.result
             self.result = self.result()
+            # Since query was async, we need to emit 'changed' signal, so
+            # override emit_signal argument.
+            emit_signal = True
+
         self.valid = True
         if emit_signal:
             self.signals['changed'].emit()

Modified: trunk/WIP/beacon2/src/server/db.py
==============================================================================
--- trunk/WIP/beacon2/src/server/db.py  (original)
+++ trunk/WIP/beacon2/src/server/db.py  Fri Jun 29 22:18:40 2007
@@ -49,7 +49,7 @@
 # get logging object
 log = logging.getLogger('beacon.db')
 
-MAX_BUFFER_CHANGES = 30
+MAX_BUFFER_CHANGES = 200
 
 # Item generation mapping
 from kaa.beacon.file import File as create_file

-------------------------------------------------------------------------
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

Reply via email to