Author: ArcRiley
Date: 2009-01-08 23:44:30 -0500 (Thu, 08 Jan 2009)
New Revision: 1449

Modified:
   trunk/concordance/src/Core.c
Log:
finished the work DavidCzech just did on signal handling, added comments 


Modified: trunk/concordance/src/Core.c
===================================================================
--- trunk/concordance/src/Core.c        2009-01-09 04:27:36 UTC (rev 1448)
+++ trunk/concordance/src/Core.c        2009-01-09 04:44:30 UTC (rev 1449)
@@ -250,28 +250,39 @@
       PyObject*         tinput;
       PyObject*         output;
       GString*          popped;
-      GTimeVal*         pop_end_time;
+      GTimeVal          popEnd;
 
     /* ensure there are no arguments save self */
     if (!PyArg_ParseTupleAndKeywords(args, kwds, ":__call__", kwlist))
       return NULL;
-      
-    g_get_current_time(pop_end_time);
-    g_time_val_add(pop_end_time,10000);
     
-    /* continuous loop */
-    while ( PyErr_CheckSignals() == 0 ) {
+    /* loop until a signal is raised
+
+       int              PyErr_CheckSignals       ();
+       Returns 0 or -1 if there's a signal
+    */
+    while (PyErr_CheckSignals() == 0) {
+      /* calculate end time to wait for next callback
+
+         void           g_get_current_time       (GTimeVal *result);
+         void           g_time_val_add           (GTimeVal *time_,
+                                                  glong microseconds);
+      */
+      g_get_current_time(&popEnd);
+      g_time_val_add(&popEnd, 10000);
+
       /* release the GIL while waiting for the next callback
 
-         gpointer       g_async_queue_pop        (GAsyncQueue *queue);
-      */
-      
+         gpointer       g_async_queue_timed_pop  (GAsyncQueue *queue,
+                                                  GTimeVal *end_time);
+      */      
       Py_BEGIN_ALLOW_THREADS
-      popped = g_async_queue_timed_pop(self->queueRecv,pop_end_time);
+      popped = g_async_queue_timed_pop(self->queueRecv, &popEnd);
       Py_END_ALLOW_THREADS
-      
-      if (popped){
 
+      /* return to start of loop if NULL is returned */
+      if (!popped) continue;
+
       /* build argument tuple
 
          PyObject*      PyUnicode_FromStringAndSize   (const char *u, 
@@ -305,9 +316,9 @@
       Py_DECREF(tinput);
       Py_DECREF(sinput);
       g_string_free(popped, TRUE);
-      }
     }
 
+    /* signal was raised, return with error condition */
     return NULL;
   }
 

_______________________________________________
PySoy-SVN mailing list
PySoy-SVN@pysoy.org
http://www.pysoy.org/mailman/listinfo/pysoy-svn

Reply via email to