MCPcopy Create free account
hub / github.com/ImageEngine/cortex / testThreadingAndClear

Method testThreadingAndClear

test/IECore/CachedReader.py:235–266  ·  view source on GitHub ↗
( self )

Source from the content-addressed store, hash-verified

233 r.read( "intDataTen.cob" )
234
235 def testThreadingAndClear( self ) :
236
237 # this tests a fix to the clear() method in the LRU cache,
238 # which was causing a crash (or at least a spurious "Previous attempt
239 # to get item failed" exception)
240
241 def func1( r, files ):
242 for i in range( 0,10000 ):
243 r.read( files[ i % len( files ) ] )
244
245 def func2( r ):
246 for i in range( 0,10000 ):
247 r.clear()
248
249 files = [
250 "test/IECore/data/cobFiles/compoundData.cob",
251 "test/IECore/data/cobFiles/intDataTen.cob",
252 "test/IECore/data/cachedReaderPath2/file.cob",
253 ]
254
255 r = IECore.CachedReader( IECore.SearchPath( "./" ), IECore.ObjectPool(100 * 1024 * 1024) )
256
257 t1 = threading.Thread( target=func1, args = [ r, files ] )
258 t2 = threading.Thread( target=func1, args = [ r, files ] )
259 t3 = threading.Thread( target=func2, args = [ r ] )
260 t1.start()
261 t2.start()
262 t3.start()
263
264 t1.join()
265 t2.join()
266 t3.join()
267
268if __name__ == "__main__":
269 unittest.main()

Callers

nothing calls this directly

Calls 5

CachedReaderMethod · 0.80
SearchPathMethod · 0.80
ObjectPoolMethod · 0.80
joinMethod · 0.80
startMethod · 0.45

Tested by

no test coverage detected