[pygobject] Fix test_mainloop.py for Python 3



commit d3225f1540e09719caa73e52d402e946da3add24
Author: Martin Pitt <martinpitt gnome org>
Date:   Tue Apr 10 12:44:00 2012 +0200

    Fix test_mainloop.py for Python 3

 tests/test_mainloop.py |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/tests/test_mainloop.py b/tests/test_mainloop.py
index 934b23b..4c7794a 100644
--- a/tests/test_mainloop.py
+++ b/tests/test_mainloop.py
@@ -4,10 +4,15 @@ import os
 import sys
 import select
 import signal
-import thread
 import time
 import unittest
 
+try:
+    from _thread import start_new_thread
+    start_new_thread  # pyflakes
+except ImportError:
+    # Python 2
+    from thread import start_new_thread
 from gi.repository import GLib
 
 from compathelper import _bytes
@@ -62,7 +67,7 @@ class TestMainLoop(unittest.TestCase):
             # create a thread which will terminate upon SIGUSR1 by way of
             # interrupting sleep()
             orig_handler = signal.signal(signal.SIGUSR1, on_usr1)
-            thread.start_new_thread(time.sleep, (10,))
+            start_new_thread(time.sleep, (10,))
 
             # now create two main loops
             loop1 = GLib.MainLoop()



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