Skip to content

Commit

Permalink
Process keyboard interruption (Control+C)
Browse files Browse the repository at this point in the history
  • Loading branch information
fedosov committed Sep 3, 2013
1 parent 885cef8 commit e716da0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions updates.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = "Mikhail Fedosov ([email protected])"
__version__ = "0.1.3.4"
__version__ = "0.1.3.5"

# http://code.activestate.com/recipes/577708-check-for-package-updates-on-pypi-works-best-in-pi/
# http://stackoverflow.com/questions/287871/print-in-terminal-with-colors-using-python
Expand Down Expand Up @@ -76,6 +76,8 @@ def check_package(dist):
msg = ""
except socket.timeout:
msg = u"{colors.FAIL}{symbols.FAIL}timeout{colors.ENDC}".format(colors=colors, symbols=symbols)
except KeyboardInterrupt:
return False

if msg:
print((u"{dist.project_name:26} {colors.BOLD}{dist.version:16}{colors.ENDC} {msg}".format(colors=colors, dist=dist, msg=msg)).encode("utf-8", "replace"))
Expand All @@ -87,7 +89,13 @@ def main():
map(check_package, pip.get_installed_distributions())
else:
pypi_pool = Pool()
pypi_pool.map(check_package, pip.get_installed_distributions())
try:
pypi_pool.map(check_package, pip.get_installed_distributions())
pypi_pool.close()
pypi_pool.join()
except KeyboardInterrupt:
print("Aborted")
pypi_pool.terminate()

if __name__ == "__main__":
main()

0 comments on commit e716da0

Please sign in to comment.