Free memory, unlock hanging threads.
cls.gl = cls.glu = cls.gle = None
if lib_gl:
- cls.gl = CDLL(lib_gl, mode=RTLD_GLOBAL)
+ try:
+ cls.gl = CDLL(lib_gl, mode=RTLD_GLOBAL)
+ except OSError:
+ pass
if lib_glu:
- cls.glu = CDLL(lib_glu, RTLD_GLOBAL)
+ try:
+ cls.glu = CDLL(lib_glu, RTLD_GLOBAL)
+ except OSError:
+ pass
if lib_gle:
try:
cls.gle = CDLL(lib_gle)
except OSError:
pass
+ @classmethod
+ def tearDownClass(cls):
+ cls.gl = cls.glu = cls.gle = None
+
def test_gl(self):
if self.gl is None:
self.skipTest('lib_gl not available')
c_long, c_ulong, c_longlong, c_ulonglong, c_double, c_float]
python_types = [int, int, int, int, int, int,
int, int, int, int, float, float]
-LargeNamedType = type('T' * 2 ** 25, (Structure,), {})
-large_string = 'T' * 2 ** 25
class PointersTestCase(unittest.TestCase):
self.assertEqual(bool(mth), True)
def test_pointer_type_name(self):
+ LargeNamedType = type('T' * 2 ** 25, (Structure,), {})
self.assertTrue(POINTER(LargeNamedType))
def test_pointer_type_str_name(self):
+ large_string = 'T' * 2 ** 25
self.assertTrue(POINTER(large_string))
if __name__ == '__main__':
self.finished.append(tid)
while not self._can_exit:
_wait()
- for i in range(n):
- start_new_thread(task, ())
+ try:
+ for i in range(n):
+ start_new_thread(task, ())
+ except:
+ self._can_exit = True
+ raise
def wait_for_started(self):
while len(self.started) < self.n:
for i in range(N_THREADS):
t = threading.Thread(target=run_thread)
threads.append(t)
- for t in threads:
- t.start()
- time.sleep(1.0)
- exit = True
+ try:
+ for t in threads:
+ t.start()
+ finally:
+ time.sleep(1.0)
+ exit = True
for t in threads:
t.join()
finally:
# received (forcing a first EINTR in write()).
read_results = []
write_finished = False
+ error = None
def _read():
- while not write_finished:
- while r in select.select([r], [], [], 1.0)[0]:
- s = os.read(r, 1024)
- read_results.append(s)
+ try:
+ while not write_finished:
+ while r in select.select([r], [], [], 1.0)[0]:
+ s = os.read(r, 1024)
+ read_results.append(s)
+ except BaseException as exc:
+ nonlocal error
+ error = exc
t = threading.Thread(target=_read)
t.daemon = True
def alarm1(sig, frame):
wio.flush()
write_finished = True
t.join()
+
+ self.assertIsNone(error)
self.assertEqual(N, sum(len(x) for x in read_results))
finally:
write_finished = True
# Issue 13454: Crash when deleting backward iterator from tee()
def test_tee_del_backward(self):
forward, backward = tee(repeat(None, 20000000))
- any(forward) # exhaust the iterator
- del backward
+ try:
+ any(forward) # exhaust the iterator
+ del backward
+ except:
+ del forward, backward
+ raise
def test_StopIteration(self):
self.assertRaises(StopIteration, next, zip())