{"action":"created","issue":{"url":"https://api.github.com/repos/boto/boto3/issues/519","repository_url":"https://api.github.com/repos/boto/boto3","labels_url":"https://api.github.com/repos/boto/boto3/issues/519/labels{/name}","comments_url":"https://api.github.com/repos/boto/boto3/issues/519/comments","events_url":"https://api.github.com/repos/boto/boto3/issues/519/events","html_url":"https://github.com/boto/boto3/issues/519","id":137257613,"number":519,"title":"KeyboardInterrupt doesn't work with 'upload_file'","user":{"login":"Miserlou","id":139987,"avatar_url":"https://avatars.githubusercontent.com/u/139987?v=3","gravatar_id":"","url":"https://api.github.com/users/Miserlou","html_url":"https://github.com/Miserlou","followers_url":"https://api.github.com/users/Miserlou/followers","following_url":"https://api.github.com/users/Miserlou/following{/other_user}","gists_url":"https://api.github.com/users/Miserlou/gists{/gist_id}","starred_url":"https://api.github.com/users/Miserlou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Miserlou/subscriptions","organizations_url":"https://api.github.com/users/Miserlou/orgs","repos_url":"https://api.github.com/users/Miserlou/repos","events_url":"https://api.github.com/users/Miserlou/events{/privacy}","received_events_url":"https://api.github.com/users/Miserlou/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-02-29T13:38:27Z","updated_at":"2016-03-01T01:22:29Z","closed_at":null,"body":"Seems like there are so many different ways of uploading a file to S3 (non-pythonic, tsk tsk).\r\n\r\nI have yet to find a combination that allows for both KeyboardInterrupts AND progress bars.\r\n\r\ns3.Bucket(bucket_name).put_object(Key=dest_path, Body=data) allows KeyboardInterrupt to work, but has no callback function.\r\n\r\nThis has the callback, but KeyboardInterrupt doesn't work.\r\n\r\ns3.meta.client.upload_file(\r\n    source_path, bucket_name, dest_path,\r\n     Callback=progress.update\r\n)\r\n\r\nSo - what's the preferred way of having a callback function and allowing KI to work?"},"comment":{"url":"https://api.github.com/repos/boto/boto3/issues/comments/190479989","html_url":"https://github.com/boto/boto3/issues/519#issuecomment-190479989","issue_url":"https://api.github.com/repos/boto/boto3/issues/519","id":190479989,"user":{"login":"kyleknap","id":4605355,"avatar_url":"https://avatars.githubusercontent.com/u/4605355?v=3","gravatar_id":"","url":"https://api.github.com/users/kyleknap","html_url":"https://github.com/kyleknap","followers_url":"https://api.github.com/users/kyleknap/followers","following_url":"https://api.github.com/users/kyleknap/following{/other_user}","gists_url":"https://api.github.com/users/kyleknap/gists{/gist_id}","starred_url":"https://api.github.com/users/kyleknap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kyleknap/subscriptions","organizations_url":"https://api.github.com/users/kyleknap/orgs","repos_url":"https://api.github.com/users/kyleknap/repos","events_url":"https://api.github.com/users/kyleknap/events{/privacy}","received_events_url":"https://api.github.com/users/kyleknap/received_events","type":"User","site_admin":false},"created_at":"2016-03-01T01:22:29Z","updated_at":"2016-03-01T01:22:29Z","body":"I am able to reproduce this with this snippet:\r\n```py\r\nimport threading\r\n\r\nimport boto3\r\nfrom boto3.s3.transfer import S3Transfer\r\n\r\nsource_path = 'testfile'\r\nbucket_name = 'mybucketfoo'\r\ndest_path = 'blah'\r\n\r\n\r\nclass ProgressPercentage(object):\r\n    def __init__(self, filename):\r\n        self._filename = filename\r\n        self._size = float(os.path.getsize(filename))\r\n        self._seen_so_far = 0\r\n        self._lock = threading.Lock()\r\n    def __call__(self, bytes_amount):\r\n        # To simplify we'll assume this is hooked up\r\n        # to a single filename.\r\n        with self._lock:\r\n            self._seen_so_far += bytes_amount\r\n            percentage = (self._seen_so_far / self._size) * 100\r\n            sys.stdout.write(\r\n                \"\\r%s  %s / %s  (%.2f%%)\" % (self._filename, self._seen_so_far,\r\n                                             self._size, percentage))\r\n            sys.stdout.flush()\r\n\r\ntransfer = S3Transfer(boto3.client('s3'))\r\ntransfer.upload_file(source_path, bucket_name, dest_path,\r\n                     callback=ProgressPercentage(source_path))\r\n```\r\nI takes me at least a few Cntrl-C's to cancel it with or without callbacks. How long does it take for your program to exit on a successful Cntrl-C? Also is your progress callbacks similar to mine?"}}