Esempio n. 1
0
 def test_setSchedulerClass(self):
    "Tests setting scheduler class and that the default scheduler is Scheduler.scheduler"
    class DummySched:
       pass
    premp = self.init_test()
    before = premp.__class__.schedulerClass
    microprocess.setSchedulerClass(DummySched)
    postmp = self.init_test()
    after = postmp.__class__.schedulerClass
    self.failUnless(before == Scheduler.scheduler, "Default scheduler not as expected!")
    self.failUnless(after == DummySched, "Set scheduler failed to set the scheduler properly")
    self.failUnless(before != after, "Setting scheduler did not change class!")
    microprocess.setSchedulerClass(before)
    resetmp=self.init_test()
    self.failUnless(resetmp.__class__.schedulerClass == Scheduler.scheduler)
Esempio n. 2
0
    def test_setSchedulerClass(self):
        "Tests setting scheduler class and that the default scheduler is Scheduler.scheduler"

        class DummySched:
            pass

        premp = self.init_test()
        before = premp.__class__.schedulerClass
        microprocess.setSchedulerClass(DummySched)
        postmp = self.init_test()
        after = postmp.__class__.schedulerClass
        self.failUnless(before == Scheduler.scheduler,
                        "Default scheduler not as expected!")
        self.failUnless(after == DummySched,
                        "Set scheduler failed to set the scheduler properly")
        self.failUnless(before != after,
                        "Setting scheduler did not change class!")
        microprocess.setSchedulerClass(before)
        resetmp = self.init_test()
        self.failUnless(
            resetmp.__class__.schedulerClass == Scheduler.scheduler)
Esempio n. 3
0
    def runThreads(self, slowmo=0):
        """\
      Runs the scheduler until there are no activated microprocesses left
      (they've all terminated).
      
      Think of this as bootstrapping the scheduler - after all it is a
      microprocess like any other, so needs something to run it!

      Keyword arguments:

      - slowmo  -- Optional. Number of seconds to wait between each cycle of executing microprocesses. (default=0 - no wait)
      """
        for i in self.main(slowmo, canblock=True):
            pass

microprocess.setSchedulerClass(scheduler)
scheduler()  # Initialise the class.

if __name__ == '__main__':
    print("This code current has no test code")

    class foo(microprocess):
        def main(self):
            while 1:
                yield 1

    a = foo()
    a.activate()
    print(a)
    scheduler.run.runThreads()
Esempio n. 4
0
   def runThreads(self,slowmo=0):
      """\
      Runs the scheduler until there are no activated microprocesses left
      (they've all terminated).
      
      Think of this as bootstrapping the scheduler - after all it is a
      microprocess like any other, so needs something to run it!

      Keyword arguments:

      - slowmo  -- Optional. Number of seconds to wait between each cycle of executing microprocesses. (default=0 - no wait)
      """
      for i in self.main(slowmo,canblock=True): pass

microprocess.setSchedulerClass(scheduler)
scheduler() # Initialise the class.


if __name__ == '__main__':
   print("This code current has no test code")
   class foo(microprocess):
      def main(self):
         while 1:
            yield 1
   a=foo()
   a.activate()
   print(a)
   scheduler.run.runThreads()