コード例 #1
0
ファイル: dsthreadtest.py プロジェクト: paul-axe/darknet
 def testPropagatingValues(self):
     dsthread.setPropagatingThreadValue("myKey", "myValue")
     self.assertEquals(dsthread.propagatingThreadValue("myKey"), "myValue")
     def lf():
         self.assertEquals(dsthread.propagatingThreadValue("myKey"), "myValue")
         dsthread.leaveNamedSection(name="mySection")
     dsthread.blockEnterNamedSection(name="mySection")
     dsthread.newThread(lf, ())
     dsthread.blockEnterNamedSection(name="mySection")
コード例 #2
0
ファイル: dsthreadtest.py プロジェクト: paul-axe/darknet
    def testMultithreadEvent(self):
        me = dsthread.MultithreadEvent()
        finishedThreads = []
        def lf():
            me.wait()
            finishedThreads.append(1)
        numThreads = 2
        for x in range(numThreads):
            dsthread.newThread(function=lf)

        self.assertEquals(len(finishedThreads), 0)
        me.set()

        time.sleep(1)

        self.assertEquals(len(finishedThreads), numThreads)