Esperar/Pausar/Sleep X Segundos una aplicacion Python [AppEngine]
En Python tenemos una libreria que podemos importar llamada Time, con la que podemos “pausar” el script X segundos.
En este ejemplo se esta importando Time y usando Sleep para dormirla y Ctime para mostrar la fecha y hora actual.
Archivo pausa.py:
# -*- encoding: utf-8 -*-
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
import time #Para poder usar el time.sleep(5)
class MainPage(webapp.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/html'
self.response.out.write("Inicio : %s" % time.ctime())
time.sleep(5) #Tiempo en segundos
self.response.out.write("<br>")
self.response.out.write("Fin : %s" % time.ctime())
application = webapp.WSGIApplication(
[('/', MainPage),
('/index.html', MainPage)],
debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()
La salida seria:
Inicio : Mon Jan 30 20:14:38 2012 Fin : Mon Jan 30 20:14:43 2012
Un archivo app.yaml sencillo:
application: [NOMBRE DE MI APLICACION] version: 1 runtime: python api_version: 1 handlers: - url: /.* script: pausa.py
Terminos de Busqueda:
- sleep en python
- error en el script de esta pagina linea 2072
- error en el script de esta pagina linea 2052
- time python
- tiempo en python
- st 2 javac no se reconoce como un comando interno o externo
- python pause
- python no reconoce response
- pausar rakion
- pausar ejecución python
- esperar x segundos en python
- esperar tiempo python
- error interno 2352 al enstalar java
- _10 cfs eliminar java