Steffen Daode Nurpmeso <sdao...@googlemail.com> added the comment: @ Charles-François Natali <rep...@bugs.python.org> wrote (2011-05-13 13:24+0200): > I happily posted a reinit patch
I must say in advance that we have implemented our own thread support 2003-2005 and i'm thus lucky not to need to use anything else ever since. So. And of course i have no overview about Python. But i looked and saw no errors in the default path and the tests run without errors. Then i started to try your semaphore path which is a bit problematic because Mac OS X doesn't offer anon sems ;). ( By the way, in PyThread_acquire_lock_timed() these lines if (microseconds > 0) MICROSECONDS_TO_TIMESPEC(microseconds, ts); result in these compiler warnings. python/thread_pthread.h: In function ‘PyThread_acquire_lock_timed’: Python/thread_pthread.h:424: warning: ‘ts.tv_sec’ may be used uninitialized in this function Python/thread_pthread.h:424: warning: ‘ts.tv_nsec’ may be used uninitialized in this function ) #ifdef USE_SEMAPHORES #define broken_sem_init broken_sem_init static int broken_sem_init(sem_t **sem, int shared, unsigned int value) { int ret; auto char buffer[32]; static long counter = 3000; sprintf(buffer, "%016ld", ++counter); *sem = sem_open(buffer, O_CREAT, (mode_t)0600, (unsigned int)value); ret = (*sem == SEM_FAILED) ? -1 : 0; //printf("BROKEN_SEM_INIT WILL RETURN %d (value=%u)\n", ret,value); return ret; } static int sem_timedwait(sem_t *sem, struct timespec *ts) { int success = -1, iters = 1000; struct timespec now, wait; printf("STARTING LOOP\n"); for (;;) { if (sem_trywait(sem) == 0) { printf("TRYWAIT OK\n"); success = 0; break; } wait.tv_sec = 0, wait.tv_nsec = 200 * 1000; //printf("DOWN "); fflush(stdout); nanosleep(&wait, NULL); MICROSECONDS_TO_TIMESPEC(0, now); //printf("WOKE UP NOW=%ld:%ld END=%ld:%ld\n", now.tv_sec,now.tv_nsec, ts->tv_sec,ts->tv_nsec); if (now.tv_sec > ts->tv_sec || (now.tv_sec == ts->tv_sec && now.tv_nsec >= ts->tv_nsec)) break; if (--iters < 0) { printf("BREAKING OFF LOOP, 1000 iterations\n"); errno = ETIMEDOUT; break; } } return success; } #define sem_destroy sem_close typedef struct _pthread_lock { sem_t *sem; struct _pthread_lock*next; sem_t sem_buf; } pthread_lock; #endif plus all the changes the struct change implies, say. Yes it's silly, but i wanted to test. And this is the result: == CPython 3.3a0 (default:804abc2c60de+, May 14 2011, 01:09:53) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] == Darwin-10.7.0-i386-64bit little-endian == /Users/steffen/src/cpython/build/test_python_19230 Testing with flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_environment=1, verbose=0, bytes_warning=0, quiet=0) Using random seed 1362049 [1/1] test_threading STARTING LOOP test_acquire_contended (test.test_threading.LockTests) ... ok test_acquire_destroy (test.test_threading.LockTests) ... ok test_acquire_release (test.test_threading.LockTests) ... ok test_constructor (test.test_threading.LockTests) ... ok test_different_thread (test.test_threading.LockTests) ... ok test_reacquire (test.test_threading.LockTests) ... ok test_state_after_timeout (test.test_threading.LockTests) ... ok test_thread_leak (test.test_threading.LockTests) ... ok test_timeout (test.test_threading.LockTests) ... STARTING LOOP TRYWAIT OK FAIL test_try_acquire (test.test_threading.LockTests) ... ok test_try_acquire_contended (test.test_threading.LockTests) ... ok test_with (test.test_threading.LockTests) ... ok test__is_owned (test.test_threading.PyRLockTests) ... ok test_acquire_contended (test.test_threading.PyRLockTests) ... ok test_acquire_destroy (test.test_threading.PyRLockTests) ... ok test_acquire_release (test.test_threading.PyRLockTests) ... ok test_constructor (test.test_threading.PyRLockTests) ... ok test_different_thread (test.test_threading.PyRLockTests) ... ok test_reacquire (test.test_threading.PyRLockTests) ... ok test_release_unacquired (test.test_threading.PyRLockTests) ... ok test_thread_leak (test.test_threading.PyRLockTests) ... ok test_timeout (test.test_threading.PyRLockTests) ... STARTING LOOP TRYWAIT OK FAIL test_try_acquire (test.test_threading.PyRLockTests) ... ok test_try_acquire_contended (test.test_threading.PyRLockTests) ... ok test_with (test.test_threading.PyRLockTests) ... ok test__is_owned (test.test_threading.CRLockTests) ... ok test_acquire_contended (test.test_threading.CRLockTests) ... ok test_acquire_destroy (test.test_threading.CRLockTests) ... ok test_acquire_release (test.test_threading.CRLockTests) ... ok test_constructor (test.test_threading.CRLockTests) ... ok test_different_thread (test.test_threading.CRLockTests) ... ok test_reacquire (test.test_threading.CRLockTests) ... ok test_release_unacquired (test.test_threading.CRLockTests) ... ok test_thread_leak (test.test_threading.CRLockTests) ... BREAKING OFF LOOP, 1000 iterations Timeout (1:00:00)! Thread 0x00007fff70677ca0: File "/Users/steffen/src/cpython/Lib/test/lock_tests.py", line 17 in _wait File "/Users/steffen/src/cpython/Lib/test/lock_tests.py", line 52 in wait_for_finished File "/Users/steffen/src/cpython/Lib/test/lock_tests.py", line 152 in test_thread_leak File "/Users/steffen/src/cpython/Lib/unittest/case.py", line 407 in _executeTestPart File "/Users/steffen/src/cpython/Lib/unittest/case.py", line 462 in run File "/Users/steffen/src/cpython/Lib/unittest/case.py", line 514 in __call__ File "/Users/steffen/src/cpython/Lib/unittest/suite.py", line 105 in run File "/Users/steffen/src/cpython/Lib/unittest/suite.py", line 67 in __call__ File "/Users/steffen/src/cpython/Lib/unittest/suite.py", line 105 in run File "/Users/steffen/src/cpython/Lib/unittest/suite.py", line 67 in __call__ File "/Users/steffen/src/cpython/Lib/unittest/runner.py", line 168 in run File "/Users/steffen/src/cpython/Lib/test/support.py", line 1187 in _run_suite File "/Users/steffen/src/cpython/Lib/test/support.py", line 1213 in run_unittest File "/Users/steffen/src/cpython/Lib/test/test_threading.py", line 748 in test_main File "/Users/steffen/src/cpython/Lib/test/regrtest.py", line 1044 in runtest_inner File "/Users/steffen/src/cpython/Lib/test/regrtest.py", line 838 in runtest File "/Users/steffen/src/cpython/Lib/test/regrtest.py", line 662 in main File "/Users/steffen/src/cpython/Lib/test/__main__.py", line 13 in <module> File "/Users/steffen/src/cpython/Lib/runpy.py", line 73 in _run_code File "/Users/steffen/src/cpython/Lib/runpy.py", line 160 in _run_module_as_main Hope that helps a bit. Bâillement. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue6721> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com