コード例 #1
0
ファイル: application.py プロジェクト: leisurelyrcxf/cmoult
def main():
    r = []
    for i in range(20):
        staticUpdatePoint()
        r.append(i)
        log(0, "v1 : " + str(i))
        time.sleep(0.5)
コード例 #2
0
ファイル: update.py プロジェクト: leisurelyrcxf/cmoult
def new_main(state):
    r = state[0]
    n = state[1]
    for i in range(20-n):
        r.append(i+n)
        log(0,"v2 : "+str(i+n))
    log(0,str(r))
コード例 #3
0
def set_thread_trace(thread, trace):
    """Sets the given trace to the given thread. Starts the trace
    immediately (does not wait forthe next function return)"""
    try:
        sys.settrace_for_thread(thread.ident, trace, True)
    except ThreadError as e:
        log(
            1, "setting trace " + trace.__name__ + " on thread " +
            str(thread.name) + " met a ThreadError : " + str(e))
コード例 #4
0
ファイル: alterability.py プロジェクト: leisurelyrcxf/cmoult
def resumeThreads(threads):
    for t in threads:
        try:
            t.resume()
        except ThreadError as e:
            log(
                1, "ThreadError when resuming thread " + str(t.name) + " : " +
                str(e))
            threads.remove(t)
コード例 #5
0
ファイル: alterability.py プロジェクト: leisurelyrcxf/cmoult
def suspendThreads(threads):
    current_thread = threading.currentThread()
    listener = get_app_listener()
    #We suspend all threads
    waited_threads = []
    for t in threads:
        if not (t is current_thread) and not (t is listener):
            try:
                t.suspend()
                if not t.wait_suspended(timeout=suspend_timeout):
                    log(1, "Timed out when suspending thread " + str(t.name))
            except ThreadError as e:
                log(
                    1, "ThreadError when suspending thread " + str(t.name) +
                    " : " + str(e))
                threads.remove(t)
コード例 #6
0
 def start_update(self):
     """Starts active update. If the active is set (active update mode),
     the thread will run the udate function set in
     active_update_function"""
     if self.active:
         if self.active_update_function is not None:
             self.active_update_function()
             self.active_update_function = None
     else:
         if hasattr(self, "static_point_event"):
             self.static_point_event.set()
             if hasattr(self, "static_wait"):
                 try:
                     self.suspend()
                 except ThreadError as e:
                     log(
                         1, "At static point, thread " + str(self.name) +
                         " met a ThreadError when suspending : " + str(e))
                 delattr(self, "static_wait")
コード例 #7
0
def updateLocalVarInThread(thread,func,name,value):
    """Changes the value of local variable name to value for 
    each frame corresponding to function func in the given thread"""
    suspended = thread.is_suspended()
    if not suspended:
        try:
            thread.suspend()
            if not thread.wait_suspended(timeout=suspend_timeout):
                log(1,"Timed out when suspending thread "+str(thread.name))
        except ThreadError as e:
            log(1,"Thread "+thread.name+" could not be suspended when updating local variable : " + str(e))
    stack_size = thread.get_stack_size()
    topframe = thread.get_current_frame()
    currentdepth = stack_size -1
    while topframe != None:
        if topframe.f_code is func.__code__:
            thread.stack_set_local(name,value,currentdepth)
        topframe = topframe.f_back
        currentdepth -= 1
    if not suspended:
        try:
            thread.resume()
        except ThreadError as e:
            log(1,"Thread "+thread.name+" could not be resumed when updating local variable : " + str(e))
コード例 #8
0
ファイル: update.py プロジェクト: leisurelyrcxf/cmoult
def func_v2():
    log(0, "v2")
コード例 #9
0
ファイル: update.py プロジェクト: leisurelyrcxf/cmoult
 def display(self):
     log(0,"An item named "+self.name+" of color "+self.color)
     log(0,"Its labels says : "+self.commentary)
コード例 #10
0
 def display(self):
     log(0, "An item named " + self.name + " of color " + self.color)
コード例 #11
0
def func_v2():
    staticUpdatePoint()
    log(0, "v2")
コード例 #12
0
ファイル: application.py プロジェクト: leisurelyrcxf/cmoult
def func_v1():
    log(0,"v1")
コード例 #13
0
def talk(n):
    text = "Hello!"
    if n > 0:
        talk(n - 1)
    time.sleep(1)
    log(0, text)