Skip to content

Commit

Permalink
make sure that we are terminating the proccess pool
Browse files Browse the repository at this point in the history
  • Loading branch information
boramalper committed Aug 16, 2016
1 parent b870866 commit 6da41e5
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions himawaripy/himawaripy.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,17 @@ def main():

png = Image.new('RGB', (width * level, height * level))

counter = Value("i", 0)
p = Pool(cpu_count() * level)
print("Downloading tiles: 0/{} completed".format(level * level), end="", flush=True)
try:
res = p.map(download_chunk, product(range(level), range(level), (requested_time,)))
except TimeoutException:
exit("\nTimeout while downloading tiles.")
counter = Value("i", 0)
p = Pool(cpu_count() * level)
print("Downloading tiles: 0/{} completed".format(level * level), end="", flush=True)
try:
res = p.map(download_chunk, product(range(level), range(level), (requested_time,)))
except TimeoutException:
exit("\nTimeout while downloading tiles.")
finally: # Make sure that we terminate proccess pool, whatever happens...
p.terminate()
p.join()

for (x, y, tiledata) in res:
tile = Image.open(BytesIO(tiledata))
Expand Down

0 comments on commit 6da41e5

Please sign in to comment.