X-Git-Url: https://git.llucax.com/z.facultad/75.52/sercom.git/blobdiff_plain/4b7437a8033c0bc66eae8be038000a86dc54c35b..edbe912983dc8aa1de548b177b07f2d514111d8c:/start-sercom.py diff --git a/start-sercom.py b/start-sercom.py old mode 100644 new mode 100755 index 57ff058..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() @@ -59,10 +68,10 @@ class Queue(object): #{{{ return None #}}} -q = Queue() -finalizer = Finalizer(name='juanca', queue=q) -t = Thread(name='juanca', target=finalizer.run) -t.start() +#q = Queue() +#finalizer = Finalizer(name='finalizer', queue=q) +#t = Thread(name='finalizer', target=finalizer.run) +#t.start() from sercom.controllers import Root