Ticket #158 (defect)

Opened 9 months ago

Last modified 9 months ago

WKB/WKT read/write is not thread safe

Status: closed (fixed)

Reported by: seang Assigned to: seang
Priority: major Milestone:
Component: Shapely Version:
Keywords: wkb wkt threads Cc:

Code:

import threading

def main():
   num_threads = 4
   use_threads = True
   
   if not use_threads:
      # Run core code
      runShapelyBuilding()
   else:
      threads = [threading.Thread(target=runShapelyBuilding) for x in range(num_threads)]
      for t in threads:
         t.start()
      for t in threads:
         t.join()
         
def runShapelyBuilding():
   import shapely.wkt
   import shapely.wkb
   
   print "Running shapely tests on wkb"
   
   wkb = shapely.wkt.loads("POINT (0 0)").wkb
   
   for i in xrange(100000):
      obj = shapely.wkb.loads(wkb)
   
   print "Done"
   
# Run main
if __name__ == '__main__':
   main()   

Change History

04/01/08 12:48:12: Modified by seang

  • status changed from new to assigned.

Looks like we need to use a stdcall prototype

http://starship.python.net/crew/theller/ctypes/reference.html#id4

04/01/08 13:28:59: Modified by seang

I think I have a fix in r1065.

04/02/08 09:17:16: Modified by seang

  • status changed from assigned to closed.
  • resolution set to fixed.