mirror of
https://github.com/nasa/trick.git
synced 2025-02-26 19:04:25 +00:00
Catching accessdenied error for mac
This commit is contained in:
parent
bdca13d8e1
commit
a6844fbeac
@ -87,6 +87,7 @@ params = Params()
|
|||||||
|
|
||||||
def is_web_server_started(port=params.get_port(), status_method="LISTEN"):
|
def is_web_server_started(port=params.get_port(), status_method="LISTEN"):
|
||||||
isConnectionOpen = False
|
isConnectionOpen = False
|
||||||
|
try:
|
||||||
for _ in range(20): #Wait up to 2 seconds i.e 20 * .1 seconds, must wait for service to get to listening state.
|
for _ in range(20): #Wait up to 2 seconds i.e 20 * .1 seconds, must wait for service to get to listening state.
|
||||||
for connection in psutil.net_connections():
|
for connection in psutil.net_connections():
|
||||||
local_address = connection.laddr
|
local_address = connection.laddr
|
||||||
@ -96,4 +97,8 @@ def is_web_server_started(port=params.get_port(), status_method="LISTEN"):
|
|||||||
if isConnectionOpen:
|
if isConnectionOpen:
|
||||||
break
|
break
|
||||||
sleep(.1) #We sleep to use less recourses
|
sleep(.1) #We sleep to use less recourses
|
||||||
|
except psutil.AccessDenied as e:
|
||||||
|
print("psutil.net_connections() requires root access on mac. Sleeping for 2 seconds instead.")
|
||||||
|
isConnectionOpen = True
|
||||||
|
sleep(2)
|
||||||
return isConnectionOpen
|
return isConnectionOpen
|
||||||
|
Loading…
x
Reference in New Issue
Block a user