pombreda / gcalcli

Automatically exported from code.google.com/p/gcalcli
0 stars 0 forks source link

fetch calendar with multiple thread #33

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This is a feature request.

Fetch event data may be slow if there are several calendars.
The data fetching time could be reduced by fetch data with multithread.

Here is a quick hack for _SearchForCalEvents():
@@ -686,6 +704,10 @@

         eventList = []

+        import threading
+        import Queue
+        queue = Queue.Queue()
+        threads = []
         for cal in self.workCals:

             if not self._CalendarWithinAccess(cal):
@@ -707,8 +729,18 @@
             # we sort later after getting events from all calendars
             #query.orderby = 'starttime'
             #query.sortorder = 'ascending'
-            feed = self.gcal.CalendarQuery(query)
+            def worker(cal, query):
+                feed = self.gcal.CalendarQuery(query)
+                queue.put((cal, feed))
+            th = threading.Thread(target=worker, args=(cal, query))
+            threads.append(th)
+            th.start()

+        for th in threads:
+            th.join()
+
+        while not queue.empty():
+            cal, feed = queue.get()
             eventList.extend(self._GetAllEvents(cal, feed))

         eventList.sort(lambda x, y:

Original issue reported on code.google.com by kuang...@gmail.com on 10 May 2008 at 5:34

GoogleCodeExporter commented 9 years ago
Added!  Thanks for this.  Great performance improvement.  Will be available in 
the next release or available now via svn.

Original comment by eda...@insanum.com on 24 Jul 2011 at 6:26

GoogleCodeExporter commented 9 years ago

Original comment by eda...@insanum.com on 24 Jul 2011 at 6:27

GoogleCodeExporter commented 9 years ago

Original comment by eda...@insanum.com on 27 Jul 2011 at 4:59