X-Git-Url: https://git.llucax.com/software/sercom.git/blobdiff_plain/4b7437a8033c0bc66eae8be038000a86dc54c35b..5e8e9e37d6f99ab10971bfb6eafe95c6d00f3088:/start-sercom.py?ds=sidebyside diff --git a/start-sercom.py b/start-sercom.py index 57ff058..fd1c7e2 100644 --- 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