mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Raise exception if command timeout is triggered (#43078)
* Raise exception if command timeout is triggered Fixes #43076 If persistent connection timeout is triggered, riase exception which will be send over socket to module code instead of silently shutting down the socket. * Fix CI failure * Fix review comment * Fix CI failure * Fix review comment * Fix review comment
This commit is contained in:
@@ -111,10 +111,9 @@ class Connection(object):
|
||||
req = request_builder(name, *args, **kwargs)
|
||||
reqid = req['id']
|
||||
|
||||
troubleshoot = 'https://docs.ansible.com/ansible/latest/network/user_guide/network_debug_troubleshooting.html#category-socket-path-issue'
|
||||
|
||||
if not os.path.exists(self.socket_path):
|
||||
raise ConnectionError('socket_path does not exist or cannot be found. Please check %s' % troubleshoot)
|
||||
raise ConnectionError('socket_path does not exist or cannot be found.'
|
||||
'\nSee the socket_path issue catergory in Network Debug and Troubleshooting Guide')
|
||||
|
||||
try:
|
||||
data = json.dumps(req)
|
||||
@@ -122,8 +121,8 @@ class Connection(object):
|
||||
response = json.loads(out)
|
||||
|
||||
except socket.error as e:
|
||||
raise ConnectionError('unable to connect to socket. Please check %s' % troubleshoot, err=to_text(e, errors='surrogate_then_replace'),
|
||||
exception=traceback.format_exc())
|
||||
raise ConnectionError('unable to connect to socket. See the socket_path issue catergory in Network Debug and Troubleshooting Guide',
|
||||
err=to_text(e, errors='surrogate_then_replace'), exception=traceback.format_exc())
|
||||
|
||||
if response['id'] != reqid:
|
||||
raise ConnectionError('invalid json-rpc id received')
|
||||
|
||||
Reference in New Issue
Block a user