Skip to content

Commit

Permalink
Merge pull request #69 from frasern/atexit
Browse files Browse the repository at this point in the history
Fixed #64 -- ensure hidden cursor is reshown at exit.
  • Loading branch information
verigak authored Jul 2, 2019
2 parents 80a91b9 + f6390b7 commit 1ed4142
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions progress/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from __future__ import division, print_function

import atexit
from collections import deque
from datetime import timedelta
from math import ceil
Expand Down Expand Up @@ -52,6 +53,7 @@ def __init__(self, message='', **kwargs):
if self.file and self.is_tty():
if self.hide_cursor:
print(HIDE_CURSOR, end='', file=self.file)
atexit.register(self.finish)
print(self.message, end='', file=self.file)
self.file.flush()

Expand Down Expand Up @@ -107,6 +109,7 @@ def finish(self):
print(file=self.file)
if self.hide_cursor:
print(SHOW_CURSOR, end='', file=self.file)
atexit.unregister(self.finish)

def is_tty(self):
try:
Expand Down

0 comments on commit 1ed4142

Please sign in to comment.