mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Make sure the socket's used are closed
This commit is contained in:
parent
7b713d9256
commit
c3417213d7
@ -552,11 +552,10 @@ def requires_network(only_local_network=False):
|
|||||||
'173.194.41.201', '173.194.41.206', '173.194.41.192',
|
'173.194.41.201', '173.194.41.206', '173.194.41.192',
|
||||||
'173.194.41.193', '173.194.41.194', '173.194.41.195',
|
'173.194.41.193', '173.194.41.194', '173.194.41.195',
|
||||||
'173.194.41.196', '173.194.41.197'):
|
'173.194.41.196', '173.194.41.197'):
|
||||||
try:
|
|
||||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
try:
|
||||||
sock.settimeout(0.25)
|
sock.settimeout(0.25)
|
||||||
sock.connect((addr, 80))
|
sock.connect((addr, 80))
|
||||||
sock.close()
|
|
||||||
# We connected? Stop the loop
|
# We connected? Stop the loop
|
||||||
break
|
break
|
||||||
except socket.error:
|
except socket.error:
|
||||||
@ -564,6 +563,8 @@ def requires_network(only_local_network=False):
|
|||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
cls.skipTest('No internet network connection was detected')
|
cls.skipTest('No internet network connection was detected')
|
||||||
|
finally:
|
||||||
|
sock.close()
|
||||||
return func(cls)
|
return func(cls)
|
||||||
return wrapper
|
return wrapper
|
||||||
return decorator
|
return decorator
|
||||||
|
Loading…
Reference in New Issue
Block a user