コード例 #1
1
ファイル: test_suite.py プロジェクト: MySheep/Archy
    def run(self):
        times = self.history.keys()
        times.sort()
        start_time = time.clock()
        elapsed_time = 0.0

        for t in times:
            force_exit_event.wait(t-elapsed_time)

            if force_exit_event.isSet():
                break
            event = self.history[t]

            import pygame_run
            pygame_run.post_tutorial_event(self, event)

            elapsed_time = time.clock() - start_time
        # end for

# At this point, either we've been told by the main Archy thread that we need to quit (meaning that the user has probably pressed a key in the middle of the tutorial), or we've run out of events to dispatch.   If the latter is the case, then we need to wait around for the main Archy thread to tell us to quit.

        force_exit_event.wait()

# At this point, our thread has exclusive control of Archy's state, since the main Archy thread is waiting for the force_exit_event event to be cleared.  Therefore, we must be certain to clear this event at the *very end* of this function, and no sooner--lest we give up our exclusive control of Archy's state and throw thread safety out the window.
        self.doOnDone()

        commands.save_and_load.saveState()

        is_running_event.clear()
        force_exit_event.clear()
コード例 #2
0
ファイル: test_suite.py プロジェクト: DanielFeichtinger/Archy
    def run(self):
        times = self.history.keys()
        times.sort()
        start_time = time.clock()
        elapsed_time = 0.0

        for t in times:
            force_exit_event.wait(t - elapsed_time)

            if force_exit_event.isSet():
                break
            event = self.history[t]

            import pygame_run
            pygame_run.post_tutorial_event(self, event)

            elapsed_time = time.clock() - start_time
        # end for


# At this point, either we've been told by the main Archy thread that we need to quit (meaning that the user has probably pressed a key in the middle of the tutorial), or we've run out of events to dispatch.   If the latter is the case, then we need to wait around for the main Archy thread to tell us to quit.

        force_exit_event.wait()

        # At this point, our thread has exclusive control of Archy's state, since the main Archy thread is waiting for the force_exit_event event to be cleared.  Therefore, we must be certain to clear this event at the *very end* of this function, and no sooner--lest we give up our exclusive control of Archy's state and throw thread safety out the window.
        self.doOnDone()

        commands.save_and_load.saveState()

        is_running_event.clear()
        force_exit_event.clear()
コード例 #3
0
ファイル: test_suite.py プロジェクト: DanielFeichtinger/Archy
    def start(self):

        # Here we do some necessary things in the main Archy thread (required for thread safety) before spawning our new movie thread.
        force_exit_event.clear()
        is_running_event.set()

        # We need to abort any special quasimode Archy may currently be in, since the movie expects us to be in a "standard" state of main text entry when it begins.
        archyState.keyState.abortCurrentQuasimode()

        threading.Thread.start(self)
コード例 #4
0
ファイル: test_suite.py プロジェクト: MySheep/Archy
    def start(self):

# Here we do some necessary things in the main Archy thread (required for thread safety) before spawning our new movie thread.
        force_exit_event.clear()
        is_running_event.set()

# We need to abort any special quasimode Archy may currently be in, since the movie expects us to be in a "standard" state of main text entry when it begins.
        archyState.keyState.abortCurrentQuasimode()

        threading.Thread.start(self)