Esempio n. 1
0
 def stop(self):
     try:
         threadSig.send(self, event=ThreadEvent.STOP)
         self._started = False
     except:
         pass
     self._pool.clear()
Esempio n. 2
0
 def start(self):
     try:
         if not self.started:
             for _ in self._pool:
                 _.setSignalSender(self)
             threadSig.send(self, event=ThreadEvent.START)
             self._started = True
     except:
         pass
Esempio n. 3
0
 def hold(self):
     try:
         threadSig.send(self, event=ThreadEvent.HOLD)
     except:
         pass
Esempio n. 4
0
 def resume(self):
     try:
         threadSig.send(self, event=ThreadEvent.RESUME)
     except:
         pass
Esempio n. 5
0
                except:
                    pass
    class TT2(PyThunderThread):

        def run(self):
            while self.running:
                try:
                    print('send start to th: {}'.format('xx198'))
                    # threadSig.send('xx198', event=ThreadEvent.START)
                    sleep(1)
                except:
                    pass
    th = TT(sender='xx198')
    tt2 = TT2()
    # tt2.start()
    threadSig.send(sender='xx198', event=ThreadEvent.START)
    sleep(2)
    threadSig.send(sender='xx198', event=ThreadEvent.HOLD)
    sleep(2)
    threadSig.send(sender='xx198', event=ThreadEvent.RESUME)
    sleep(2)
    print('-' * 40)
    group = Group()
    [group.add(TT()) for _ in range(5)]
    group.start()
    # sleep(50)
    print('started---->')
    sleep(5)
    print('will hold --->')
    group.hold()
    sleep(5)