Permalink
Browse files

ENH Exit when there is no progress (with barrier)

Previously, this condition resulted in an active wait loop
  • Loading branch information...
1 parent 1d3fd49 commit 3f61dcd1b99fb33243bfcac6f05031474fe13193 @luispedro committed Dec 28, 2012
Showing with 14 additions and 2 deletions.
  1. +1 −0 ChangeLog
  2. +13 −2 jug/jug.py
View
@@ -1,6 +1,7 @@
version 0.9.3+
* Add CustomHash wrapper to set __jug_hash__
* Print traceback on import error
+ * Exit when no progress is made even with barrier
version 0.9.3 Sun Dec 2 2012 by luispedro
* Fix parsing of ports on redis URL (patch by Alcides Viamontes)
View
@@ -193,12 +193,23 @@ def execute(options):
tasks_executed = defaultdict(int)
tasks_loaded = defaultdict(int)
store = None
- done = False
- while not done:
+ noprogress = 0
+ while noprogress < 32:
del tasks[:]
store,jugspace = init(options.jugfile, options.jugdir, store=store)
+ previous = sum(tasks_executed.values())
execution_loop(tasks, options, tasks_executed, tasks_loaded)
+ after = sum(tasks_executed.values())
done = not jugspace.get('__jug__hasbarrier__', False)
+ if done:
+ break
+ if after == previous:
+ from time import sleep
+ noprogress += 1
+ sleep(options.execute_wait_cycle_time_secs)
+ else:
+ logging.info('No tasks can be run!')
+
options.print_out('%-52s%12s%12s' %('Task name','Executed','Loaded'))
options.print_out('-' * (52+12+12))

0 comments on commit 3f61dcd

Please sign in to comment.