Skip to content

Commit

Permalink
Issue #114: call close on FileExecutor and Harvester
Browse files Browse the repository at this point in the history
At the end of the job, after processing all the files, call close on
FileExecutor and Harvester.

This allows to do clean up stuff like shutting down any runner still
alive in the FileExecutor.
  • Loading branch information
eldipa committed Mar 24, 2021
1 parent b274eec commit 2ba664c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions byexample/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ def reset_runners(self, runners, should_raise=True, force_shutdown=True):

assert not left

@log_context('byexample.close')
def close(self):
self.reset_runners(
self.still_alive_runners, should_raise=True, force_shutdown=True
)

def __repr__(self):
return 'File Executor'

Expand Down
4 changes: 4 additions & 0 deletions byexample/finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ def __init__(

self.options = options

@log_context('byexample.close')
def close(self):
pass

def __repr__(self):
return 'Example Harvester'

Expand Down
3 changes: 3 additions & 0 deletions byexample/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ def worker(func, input, output, cfg):
for item in iter(input.get, None):
output.put(func(item, harvester, executor, cfg['dry']))

harvester.close()
executor.close()


class Jobs(object):
def __init__(self, njobs):
Expand Down

0 comments on commit 2ba664c

Please sign in to comment.