+++ /dev/null
-# This is a helper module for test_threaded_import. The test imports this\r
-# module, and this module tries to run various Python library functions in\r
-# their own thread, as a side effect of being imported. If the spawned\r
-# thread doesn't complete in TIMEOUT seconds, an "appeared to hang" message\r
-# is appended to the module-global `errors` list. That list remains empty\r
-# if (and only if) all functions tested complete.\r
-\r
-TIMEOUT = 10\r
-\r
-import threading\r
-\r
-import tempfile\r
-import os.path\r
-\r
-errors = []\r
-\r
-# This class merely runs a function in its own thread T. The thread importing\r
-# this module holds the import lock, so if the function called by T tries\r
-# to do its own imports it will block waiting for this module's import\r
-# to complete.\r
-class Worker(threading.Thread):\r
- def __init__(self, function, args):\r
- threading.Thread.__init__(self)\r
- self.function = function\r
- self.args = args\r
-\r
- def run(self):\r
- self.function(*self.args)\r
-\r
-for name, func, args in [\r
- # Bug 147376: TemporaryFile hung on Windows, starting in Python 2.4.\r
- ("tempfile.TemporaryFile", tempfile.TemporaryFile, ()),\r
-\r
- # The real cause for bug 147376: ntpath.abspath() caused the hang.\r
- ("os.path.abspath", os.path.abspath, ('.',)),\r
- ]:\r
-\r
- t = Worker(func, args)\r
- t.start()\r
- t.join(TIMEOUT)\r
- if t.is_alive():\r
- errors.append("%s appeared to hang" % name)\r