Skip to content

Commit

Permalink
removed pushing to no-target, thereby redefining work in the system, …
Browse files Browse the repository at this point in the history
…and added start delay
  • Loading branch information
nickdelgrosso committed Dec 29, 2018
1 parent 2f52c8e commit b16e240
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 2 additions & 4 deletions leansim/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ def push(self):
else:
to_push = 0

if to_push:
if not self.target:
self.done -= to_push
elif not self.target.max_todo or (self.target.max_todo >= self.target.todo + len(self.target.doing) + to_push):
if to_push and self.target:
if not self.target.max_todo or (self.target.max_todo >= self.target.todo + len(self.target.doing) + to_push):
self.target.todo += to_push
self.done -= to_push

Expand Down
8 changes: 6 additions & 2 deletions leansim/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def __init__(self, workers):

@property
def total_work(self):
return sum(w.wip + w.done for w in self.workers)
return sum(w.wip + w.done for w in self.workers) - self.workers[-1].done

@property
def wip(self):
Expand All @@ -25,9 +25,13 @@ def step(self):
worker.push()
self.work_done += work_done

def process(self, work, verbose=False, sleep_time=0):
def process(self, work, verbose=False, sleep_time=0, start_delay=1.5):
"""Returns number of steps to process some piece of work."""
self.workers[0].todo = work
if verbose:
os.system('cls' if os.name == 'nt' else 'clear')
print(self)
sleep(start_delay)
steps = 0
while self.total_work:
steps += 1
Expand Down

0 comments on commit b16e240

Please sign in to comment.