donnemartin / saws

A supercharged AWS command line interface (CLI).
Other
5.24k stars 281 forks source link

Saws exits when aws is working in the background then terminated with Control-C. #33

Closed confiq closed 8 years ago

confiq commented 8 years ago

Example, if I run following command:

aws route53 list-hosted-zones

or any command that takes time... if I want to exit I'll probably use "Control+c" (or Alt+c in linux). The problem is that I want to stop aws command and not saws. With this command, saws exits

CTraceback (most recent call last):
  File "/usr/local/bin/pygmentize", line 11, in <module>
    sys.exit(main())
  File "/Library/Python/2.7/site-packages/pygments/cmdline.py", line 505, in main
Traceback (most recent call last):
  File "/usr/local/bin/aws", line 27, in <module>
    sys.exit(main())
  File "/usr/local/bin/aws", line 23, in main
    return awscli.clidriver.main()
  File "/Library/Python/2.7/site-packages/awscli/clidriver.py", line 48, in main
    return driver.main()
  File "/Library/Python/2.7/site-packages/awscli/clidriver.py", line 183, in main
    return main_inner(popts, args, usage)
  File "/Library/Python/2.7/site-packages/pygments/cmdline.py", line 380, in main_inner
    return command_table[parsed_args.command](remaining, parsed_args)
  File "/Library/Python/2.7/site-packages/awscli/clidriver.py", line 369, in __call__
    code = sys.stdin.read()
KeyboardInterrupt
    return command_table[parsed_args.operation](remaining, parsed_globals)
  File "/Library/Python/2.7/site-packages/awscli/clidriver.py", line 538, in __call__
    call_parameters, parsed_globals)
  File "/Library/Python/2.7/site-packages/awscli/clidriver.py", line 662, in invoke
    **parameters)
  File "/Library/Python/2.7/site-packages/botocore/client.py", line 268, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/Library/Python/2.7/site-packages/botocore/client.py", line 322, in _make_api_call
    operation_model, request_dict)
  File "/Library/Python/2.7/site-packages/botocore/endpoint.py", line 111, in make_request
    return self._send_request(request_dict, operation_model)
  File "/Library/Python/2.7/site-packages/botocore/endpoint.py", line 138, in _send_request
    request, operation_model, attempts)
  File "/Library/Python/2.7/site-packages/botocore/endpoint.py", line 168, in _get_response
    proxies=self.proxies, timeout=self.timeout)
  File "/Library/Python/2.7/site-packages/botocore/vendored/requests/sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "/Library/Python/2.7/site-packages/botocore/vendored/requests/adapters.py", line 370, in send
    timeout=timeout
  File "/Library/Python/2.7/site-packages/botocore/vendored/requests/packages/urllib3/connectionpool.py", line 544, in urlopen
    body=body, headers=headers)
  File "/Library/Python/2.7/site-packages/botocore/vendored/requests/packages/urllib3/connectionpool.py", line 341, in _make_request
    self._validate_conn(conn)
  File "/Library/Python/2.7/site-packages/botocore/vendored/requests/packages/urllib3/connectionpool.py", line 761, in _validate_conn
    conn.connect()
  File "/Library/Python/2.7/site-packages/botocore/vendored/requests/packages/urllib3/connection.py", line 204, in connect
    conn = self._new_conn()
  File "/Library/Python/2.7/site-packages/botocore/vendored/requests/packages/urllib3/connection.py", line 134, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "/Library/Python/2.7/site-packages/botocore/vendored/requests/packages/urllib3/util/connection.py", line 78, in create_connection
    sock.connect(sa)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 228, in meth
    return getattr(self._sock,name)(*args)
KeyboardInterrupt
donnemartin commented 8 years ago

@confiq: Took a quick look, seems like a relatively straightforward fix. I'll try to get it in later today.

donnemartin commented 8 years ago

Reopening due to issues on the Windows side. See discussion here: https://github.com/donnemartin/saws/commit/52130e8ef6b088d8eb562f0d90060993217d9258.

donnemartin commented 8 years ago

Reopening due to issues on the Windows side

On Windows, the "Terminate batch job (Y/N)" confirmation makes it tricky to handle this gracefully. Thus, we re-raise KeyboardInterrupt. See 31b4344ced0c3ea8c5de1f3034370b90cb502689.

I don't plan to try to fix this on Windows at this time. If there is more interest I'm happy to re-evaluate in the future.