diff test_pymonkey.py @ 66:b49180c39d0a

Pymonkey now handles the GIL properly so that Python code can run while JS code does.
author Atul Varma <varmaa@toolness.com>
date Sun, 26 Jul 2009 15:06:19 -0700
parents fb7e11dec538
children 9b3f4e53e365
line wrap: on
line diff
--- a/test_pymonkey.py	Sun Jul 26 13:09:58 2009 -0700
+++ b/test_pymonkey.py	Sun Jul 26 15:06:19 2009 -0700
@@ -1,6 +1,8 @@
 import sys
 import unittest
 import weakref
+import time
+import threading
 
 import pymonkey
 
@@ -38,12 +40,12 @@
         obj = cx.new_object()
         cx.init_standard_classes(obj)
 
-        # TODO: This isn't a very good test; we need to actually
-        # set up a signal or launch a separate thread to call
-        # this method as though it were a watchdog to limit the
-        # amount of time the JS can run. However, Pymonkey doesn't
-        # yet handle the GIL properly so this isn't possible.
-        cx.trigger_operation_callback()
+        def watchdog():
+            time.sleep(0.1)
+            cx.trigger_operation_callback()
+
+        thread = threading.Thread(target = watchdog)
+        thread.start()
 
         self.assertRaises(
             pymonkey.error,