Opened 19 years ago
Closed 19 years ago
#1319 closed defect (fixed)
threading test locks up python on windows
Reported by: | Owned by: | warmerdam | |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | MapScript | Version: | 4.5 |
Severity: | normal | Keywords: | |
Cc: |
Description
But passes on Linux. In the windows case, mapserver was build with /MD and USE_THREAD. Here is the test (tests/cases/threadtest.py 1.6): import os, sys import unittest # the testing module helps us import the pre-installed mapscript from testing import mapscript, TESTMAPFILE def make_map(i): print "making map in thread %d" % (i) print mapscript.MS_ON po = mapscript.pointObj(1,1) print po class MultipleThreadsTestCase(unittest.TestCase): def testLayerAdditionMultiThreads(self): """mapscripting in multiple threads""" import threading workers = [] for i in range(10): thread = threading.Thread(target=make_map, args=(i,)) workers.append(thread) thread.start() for thread in workers: print "waiting ... " + str(thread) thread.join() print str(thread) + " done." # ----------------------------------------------------------------------------- if __name__ == '__main__': unittest.main() the make_map() function is run by the 10 "worker" threads. Curious that even an operation as simple as init-ing a pointObj hangs. Note that printing the module variable mapscript.MS_ON works just fine by itself. I also substituted code from a non-mapscript module into make_map() and had no problems at all.
Change History (5)
comment:2 by , 19 years ago
Status: | new → assigned |
---|
As Sean noted, windows multithreading support was completely borked, and has been since the beginning of time. The initialization function was creating the mutexes as "creator owned" and so no other thread was ever able to acquire them. It worked in single threaded mode, since multi-acquisition of a mutex by the same thread is permitted on win32. The fix is comitted in the 4.5 stream. If we are ever going to have a 4.4.3 the fix should be migrated back. Just change the mutex creation from this: for( ; mutexes_initialized < TLOCK_STATIC_MAX; mutexes_initialized++ ) mutex_locks[mutexes_initialized] = CreateMutex( NULL, TRUE, NULL ); to this: for( ; mutexes_initialized < TLOCK_STATIC_MAX; mutexes_initialized++ ) mutex_locks[mutexes_initialized] = CreateMutex( NULL, FALSE, NULL ); in mapthread.c I'm not closing till someone verifies the fix, and we discuss whether it needs to be backported.
comment:4 by , 19 years ago
Frank, thread initialization seems to be fixed. I committed 2 new tests (threadtest.py 1.7). One triggers exceptions in all worker threads, the other triggers an exception in one thread and makes valid requests in subsequent threads as a simple-minded effort to check that exceptions are contained to one thread. All the tests pass on windows and linux with USE_THREAD. Do we need a 4.4.3 release? I don't know. While the number of multi-threading users is growing, it's much smaller than the traditional CGI users. Cutting a 4.4.3 release that most users could ignore might cause some confudion. It's more important that those of us distributing 4.4.x or 4.5 windows mapscript binaries make the fix and update our binaries.
comment:5 by , 19 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Closing ... I don't think there will be a 4.4.3 now that we are into the 4.6 betas.
Note:
See TracTickets
for help on using tickets.