X-Git-Url: https://git.llucax.com/z.facultad/75.52/sercom.git/blobdiff_plain/fe57b6c5949830f40ce8bf4d096da1f34bc3d734..edbe912983dc8aa1de548b177b07f2d514111d8c:/start-sercom.py?ds=sidebyside diff --git a/start-sercom.py b/start-sercom.py old mode 100644 new mode 100755 index 0ec9722..fd1c7e2 --- a/start-sercom.py +++ b/start-sercom.py @@ -25,7 +25,7 @@ elif exists(join(dirname(__file__), "setup.py")): else: update_config(configfile="prod.cfg",modulename="sercom.config") -from sercom.model import InstanciaDeEntrega, hub +from sercom.model import InstanciaDeEntrega, Entrega, AND, hub from sercom.finalizer import Finalizer from threading import Thread from datetime import datetime @@ -42,8 +42,17 @@ class Queue(object): #{{{ try: hub.begin() try: - select = InstanciaDeEntrega.selectBy(inicio_proceso=None) + select = InstanciaDeEntrega.select(AND( + InstanciaDeEntrega.q.inicio_proceso == None, + InstanciaDeEntrega.q.fin <= datetime.now())) instancia = select.orderBy(InstanciaDeEntrega.q.fin)[0] + n = Entrega.selectBy(instancia=instancia, fin=None).count() + if n: + log.debug(_(u'Esperando para procesar instancia (%s), ' + 'faltan probar %s entregas'), instancia.shortrepr(), + n) + time.sleep(30) + continue instancia.inicio_proceso = datetime.now() finally: hub.commit() @@ -60,8 +69,8 @@ class Queue(object): #{{{ #}}} #q = Queue() -#finalizer = Finalizer(name='juanca', queue=q) -#t = Thread(name='juanca', target=finalizer.run) +#finalizer = Finalizer(name='finalizer', queue=q) +#t = Thread(name='finalizer', target=finalizer.run) #t.start() from sercom.controllers import Root