当前位置: 首页>>代码示例>>Python>>正文


Python Timer.cancel方法代码示例

本文整理汇总了Python中Timer.cancel方法的典型用法代码示例。如果您正苦于以下问题:Python Timer.cancel方法的具体用法?Python Timer.cancel怎么用?Python Timer.cancel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Timer的用法示例。


在下文中一共展示了Timer.cancel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_supports_Timer_interface

# 需要导入模块: import Timer [as 别名]
# 或者: from Timer import cancel [as 别名]
    def test_supports_Timer_interface(self):
        x = Timer()
        x.stop()

        tref = Mock()
        x.cancel(tref)
        tref.cancel.assert_called_with()

        assert x.schedule is x
开发者ID:Erve1879,项目名称:kombu,代码行数:11,代码来源:test_timer.py

示例2: test_cancel

# 需要导入模块: import Timer [as 别名]
# 或者: from Timer import cancel [as 别名]
 def test_cancel(self):
     t = Timer()
     tref = Mock()
     t.cancel(tref)
     tref.cancel.assert_called_with()
开发者ID:Erve1879,项目名称:kombu,代码行数:7,代码来源:test_timer.py

示例3: run_hefesto_morb

# 需要导入模块: import Timer [as 别名]
# 或者: from Timer import cancel [as 别名]
def run_hefesto_morb():
    for thing in os.listdir(home_dir_list[0] + "/MORB_Control_Files"):
        print "\n" + "Opening HeFESTo for " + str(thing) + "\n"
        time.sleep(2)
        if "control" in os.listdir(home_dir_list[0]):
            os.remove(home_dir_list[0] + "/control")
        else:
            pass
        os.chdir(home_dir_list[0] + "/MORB_Control_Files")
        print "Copying" + str(thing) + " to path " + home_dir_list[0] + "..." + "\n"
        todir = home_dir_list[0] + "/" + "control"
        copyfromdir = home_dir_list[0] + "/MORB_Control_Files/" + str(thing)
        shutil.copy(copyfromdir, todir)
        os.chdir(home_dir_list[0])
        #src = str(thing)
        #drc = "control"
        #os.rename(src, drc)
        print("Performing calculations on {thing!r} ...".format(**vars()))
        print "\n"
        print "\n" + "Opening HeFESTo for calculations on " + str(thing) + " ..." + "\n"
        print "\n"
        #working_dir = os.curdir()
        #Popen(["main"], cwd=working_dir, stdin=PIPE)
        argz = home_dir_list[0] + "/main"
        p = subprocess.Popen(argz, stdin=None, stdout=None)
        t = Timer(800, p.kill)
        print "\n" + "Timeout timer started.  800 seconds until the process is terminated and the loop continues..." + "\n"
        t.start()
        t.communicate()
        t.cancel()
        print "\n" + "Copying output files to" +  home_dir_list[0]+ "/MORB_Output_Files' directory..." + "\n"
        try:
            os.remove("control")
        except:
            print "\n" + "Control file not found!" + "\n"
            pass
        if "fort.66" in os.listdir(home_dir_list[0]):
            print "\n" + "fort.66 found!" + "\n"
            theoutputfile66 = home_dir_list[0] + "/" + "fort.66"
            outputtodir66 = home_dir_list[0] + "/MORB_Output_Files/fort.66_files/" + "fort.66."+str(thing)+"_morb"
            shutil.move(theoutputfile66, outputtodir66)
        else:
            print "fort.66." + str(thing) + " not found!"
            pass
        if "fort.58" in os.listdir(home_dir_list[0]):
            print "\n" + "fort.58 found!" + "\n"
            theoutputfile58 = home_dir_list[0] + "/" + "fort.58"
            outputtodir58 = home_dir_list[0] + "/MORB_Output_Files/fort.58_files/" + "fort.58."+str(thing)+"_morb"
            shutil.move(theoutputfile58, outputtodir58)
        else:
            print "fort.58." + str(thing) + " not found!"
            pass
        if "fort.59" in os.listdir(home_dir_list[0]):
                print "\n" + "fort.59 found!" + "\n"
                theoutputfile59 = home_dir_list[0] + "/" + "fort.59"
                outputtodir59 = home_dir_list[0] + "/MORB_Output_Files/fort.59_files/" + "fort.59."+str(thing)+"_morb"
                shutil.move(theoutputfile59, outputtodir59)
        else:
            print "fort.59." + str(thing) + " not found!"
            pass
        print "LOOP FINISHED FOR " + str(thing)
        time.sleep(2)
        #except Exception:
           # traceback.print_exc()
           # print "\n"
           # print "Calculation failure for " + str(thing) + ".  Moving on..."
           # print "\n"
    else:
        print "\n"
        print "Done with MORB HeFESTo calculations.  Exiting script..." + "\n\n\n\n"
        print "___________________________________________________________"
        print "\n"
开发者ID:ScottHull,项目名称:Exoplanet-Pocketknife,代码行数:74,代码来源:EP_AutoHeFESTo.py


注:本文中的Timer.cancel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。