Run script in python every second

0

Friends I am developing a script in python, I think this compile to .exe. and for that I'm using cx_Freeze.

Now in my .py I want to develop a function that I run the script automatically every 5 sec and for this I am using:

scheduler = Scheduler()
scheduler.add(5, 0, funcion)
while True:
    scheduler.run()

But the problem was that when I compiled it, why could not execute the .exe successfully. Apparently I have solved it by changing some parameters of the script. I am testing the script in several ways, until now it is working ... I will continue with the testing, but for now I will not close the question. I receive all kinds of suggestions ....

    
asked by Nahuel Jakobson 01.04.2016 в 23:29
source

1 answer

2

You can use time.sleep () , defining that every second your "script" is executed:

import time

def ejecutaScript():
    #Aquí agregas en contenido de tu script o ejecutas el script dentro de un archivo .py.
    python myscript.py
    print 'Ejecutando Script...'
    time.sleep(1)

while True:
    ejecutaScript()
    
answered by 02.04.2016 в 02:28