Exemple #1
0
 def ret_func(*args, **kwargs):
     is_top_level = False
     this_task = get_scheduler().try_get_task_for_curr_thread()
     if this_task is None:
         is_top_level = True
         this_task = get_scheduler().create_and_register_task_for_top_level(
         )
         get_scheduler().sched()
         this_task.wait_for_turn()
     try:
         if is_top_level:
             from niveristand.clientapi import RealTimeSequence
             RealTimeSequence(func)
         retval = func(*args, **kwargs)
     except errors.SequenceError:
         # generate error already saved this error in the task, so we can just pass.
         pass
     finally:
         if is_top_level:
             this_task.mark_stopped()
             this_task.iteration_counter.finished = True
             nivs_yield()
             if this_task.error and this_task.error.should_raise:
                 raise errors.RunError.RunErrorFactory(this_task.error)
     return retval
 def _internal_task(task_info):
     # all tasks start waiting for their turn from the scheduler.
     task_info.wait_for_turn()
     try:
         return func()
     except (errors._StopTaskException, errors.SequenceError):
         pass
     finally:
         # if the task was stopped or it finished execution mark it stopped, then yield.
         # It won't get scheduled again, and the thread will be marked finished.
         task_info.mark_stopped()
         nivs_yield()