我试图每 10 秒重新运行一次我的 python 脚本。我已经尝试了 time.sleep 函数的各种方法,但似乎没有任何效果。我尝试过 time.sleep 的不同变体:
def job()
# script
if __name__ == '__main__':
while True:
job()
time.sleep(10)
但没有找到正确的地点/方式来实施它。我不想重新运行函数,而是完整的代码。
这是我尝试重新运行的脚本:
import...
def main():
# parse the command line arguments
args = ConfigArgumentParser(description=__doc__).parse_args()
if _debug: _log.debug("initialization")
if _debug: _log.debug(" - args: %r", args)
# make a device object
this_device = LocalDeviceObject(
objectName=args.ini.objectname,
objectIdentifier=('device', int(args.ini.objectidentifier)),
maxApduLengthAccepted=int(args.ini.maxapdulengthaccepted),
segmentationSupported=args.ini.segmentationsupported,
vendorIdentifier=int(args.ini.vendoridentifier),
)
# make a sample application
this_application = BIPSimpleApplication(this_device, args.ini.address)
# make some random input objects
for i in range(1, RANDOM_OBJECT_COUNT + 1):
ravo = RandomAnalogValueObject(
objectIdentifier=('analogValue', i),
objectName='Temp%d' % (i,),
)
this_application.add_object(ravo)
# make sure they are all there
_log.debug(" - object list: %r", this_device.objectList)
_log.debug("running")
run()
_log.debug("fini")
if __name__ == "__main__":
main()
米脂
RISEBY
慕哥6287543
相关分类