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

Method testCancelLoading

test/IECoreScene/PrimitiveTest.py:178–210  ·  view source on GitHub ↗
( self )

Source from the content-addressed store, hash-verified

176
177 @unittest.skipIf( ( IECore.TestUtil.inMacCI() or IECore.TestUtil.inWindowsCI() ), "Mac and Windows CI are too slow for reliable timing" )
178 def testCancelLoading( self ) :
179
180 strip = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( 0 ), imath.V2f( 100000, 1 ) ), imath.V2i( 1000000, 1 ) )
181 testData = IECore.FloatVectorData( [0] * ( len( strip["P"].data ) ) )
182 for i in range( 10 ):
183 q = IECore.FloatVectorData( testData )
184 q[0] = i
185 strip["var%i" % i] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, q )
186
187 saveIO = IECore.MemoryIndexedIO( IECore.CharVectorData(), IECore.IndexedIO.OpenMode.Write )
188 strip.save( saveIO, "test" )
189 loadIO = IECore.MemoryIndexedIO( saveIO.buffer(), IECore.IndexedIO.OpenMode.Read )
190
191 canceller = IECore.Canceller()
192 cancelled = [False]
193
194 def backgroundRun():
195 try:
196 IECore.Object.load( loadIO, "test", canceller )
197 except IECore.Cancelled:
198 cancelled[0] = True
199
200 thread = threading.Thread(target=backgroundRun, args=())
201
202 startTime = time.time()
203 thread.start()
204
205 time.sleep( 0.01 )
206 canceller.cancel()
207 thread.join()
208
209 self.assertLess( time.time() - startTime, 0.1 )
210 self.assertTrue( cancelled[0] )
211
212if __name__ == "__main__":
213 unittest.main()

Callers

nothing calls this directly

Calls 10

cancelMethod · 0.95
createPlaneMethod · 0.80
PrimitiveVariableMethod · 0.80
MemoryIndexedIOMethod · 0.80
CancellerMethod · 0.80
joinMethod · 0.80
lenFunction · 0.50
saveMethod · 0.45
bufferMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected