[tracker/introspection] functional-tests: example of opening connection asynchronously



commit ab3d1d6f9a8e74b7d55711c7d5effe21113d21f8
Author: Ivan Frade <ivan frade nokia com>
Date:   Mon Apr 4 16:29:35 2011 +0300

    functional-tests: example of opening connection asynchronously

 examples/introspection/python/all-async.py |   30 ++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/examples/introspection/python/all-async.py b/examples/introspection/python/all-async.py
new file mode 100644
index 0000000..207e3fd
--- /dev/null
+++ b/examples/introspection/python/all-async.py
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+import gi
+from gi.repository import Tracker, GObject
+
+def results_ready_cb (obj, result, user_data):
+    cursor = obj.query_finish (result)
+
+    # This can also be done asynchronously
+    while (cursor.next (None)):
+        print cursor.get_string (0)
+
+    user_data.quit ()
+
+
+def connection_ready_cb (object, result, user_data):
+    assert user_data
+    conn = Tracker.SparqlConnection.get_finish (result)
+
+    conn.query_async ("SELECT ?u WHERE { ?u a nie:InformationElement. }",
+                      None,
+                      results_ready_cb,
+                      user_data)
+
+    
+if __name__ == "__main__":
+    loop = GObject.MainLoop ()
+
+    Tracker.SparqlConnection.get_async (None, connection_ready_cb, loop)
+
+    loop.run ()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]