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
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()
#}}}
#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