We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Run tests on windows and OSX
Part of the reason we wanted tests with remote databases was to be able to test mindsdb on windows and OSX.

This is currently being done for native but not for mindsdb,  current issues that stop us from testing on OSX and windows:

* `psutil.net_connections` requires root privileges on osx/windows
* `ssh` command will fail on windows
* ??? 

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `mindsdb/utilities/ps.py`
Content:
```
1 import psutil
2 import time
3 
4 
5 def is_port_in_use(port_num):
6     portsinuse = []
7     conns = psutil.net_connections()
8     portsinuse = [x.laddr[1] for x in conns if x.status == 'LISTEN']
9     portsinuse.sort()
10     return int(port_num) in portsinuse
11 
12 
13 def wait_func_is_true(func, timeout, *args, **kwargs):
14     start_time = time.time()
15 
16     result = func(*args, **kwargs)
17     while result is False and (time.time() - start_time) < timeout:
18         time.sleep(2)
19         result = func(*args, **kwargs)
20 
21     return result
22 
23 
24 def wait_port(port_num, timeout):
25     return wait_func_is_true(func=is_port_in_use, timeout=timeout, port_num=port_num)
26 
27 
28 def get_listen_ports(pid):
29     try:
30         p = psutil.Process(pid)
31         cons = p.connections()
32         cons = [x.laddr.port for x in cons]
33     except Exception:
34         return []
35     return cons
36 
37 
38 def is_pid_listen_port(pid, port):
39     ports = get_listen_ports(pid)
40     return int(port) in ports
41
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/mindsdb/utilities/ps.py b/mindsdb/utilities/ps.py
--- a/mindsdb/utilities/ps.py
+++ b/mindsdb/utilities/ps.py
@@ -1,11 +1,44 @@
-import psutil
+import sys
 import time
+from collections import namedtuple
+import psutil
+
+
+def net_connections():
+    """Cross-platform psutil.net_connections like interface"""
+    if sys.platform.lower().startswith('linux'):
+        return psutil.net_connections()
+
+    all_connections = []
+    Pconn = None
+    for p in psutil.process_iter(['pid']):
+        try:
+            process = psutil.Process(p.pid)
+            connections = process.connections()
+            if connections:
+                for conn in connections:
+                    # Adding pid to the returned instance
+                    # for consistency with psutil.net_connections()
+                    if Pconn is None:
+                        fields = list(conn._fields)
+                        fields.append('pid')
+                        _conn = namedtuple('Pconn', fields)
+                    for attr in conn._fields:
+                        setattr(_conn, attr, getattr(conn, attr))
+                    _conn.pid = p.pid
+                    all_connections.append(_conn)
+
+        except (psutil.AccessDenied, psutil.ZombieProcess, psutil.NoSuchProcess):
+            pass
+    return all_connections
 
 
 def is_port_in_use(port_num):
-    portsinuse = []
-    conns = psutil.net_connections()
-    portsinuse = [x.laddr[1] for x in conns if x.status == 'LISTEN']
+    """Check does any of child process uses specified port."""
+    parent_process = psutil.Process()
+    child_pids = [x.pid for x in parent_process.children(recursive=True)]
+    conns = net_connections()
+    portsinuse = [x.laddr[1] for x in conns if x.pid in child_pids and x.status == 'LISTEN']
     portsinuse.sort()
     return int(port_num) in portsinuse

{"golden_diff": "diff --git a/mindsdb/utilities/ps.py b/mindsdb/utilities/ps.py\n--- a/mindsdb/utilities/ps.py\n+++ b/mindsdb/utilities/ps.py\n@@ -1,11 +1,44 @@\n-import psutil\n+import sys\n import time\n+from collections import namedtuple\n+import psutil\n+\n+\n+def net_connections():\n+    \"\"\"Cross-platform psutil.net_connections like interface\"\"\"\n+    if sys.platform.lower().startswith('linux'):\n+        return psutil.net_connections()\n+\n+    all_connections = []\n+    Pconn = None\n+    for p in psutil.process_iter(['pid']):\n+        try:\n+            process = psutil.Process(p.pid)\n+            connections = process.connections()\n+            if connections:\n+                for conn in connections:\n+                    # Adding pid to the returned instance\n+                    # for consistency with psutil.net_connections()\n+                    if Pconn is None:\n+                        fields = list(conn._fields)\n+                        fields.append('pid')\n+                        _conn = namedtuple('Pconn', fields)\n+                    for attr in conn._fields:\n+                        setattr(_conn, attr, getattr(conn, attr))\n+                    _conn.pid = p.pid\n+                    all_connections.append(_conn)\n+\n+        except (psutil.AccessDenied, psutil.ZombieProcess, psutil.NoSuchProcess):\n+            pass\n+    return all_connections\n \n \n def is_port_in_use(port_num):\n-    portsinuse = []\n-    conns = psutil.net_connections()\n-    portsinuse = [x.laddr[1] for x in conns if x.status == 'LISTEN']\n+    \"\"\"Check does any of child process uses specified port.\"\"\"\n+    parent_process = psutil.Process()\n+    child_pids = [x.pid for x in parent_process.children(recursive=True)]\n+    conns = net_connections()\n+    portsinuse = [x.laddr[1] for x in conns if x.pid in child_pids and x.status == 'LISTEN']\n     portsinuse.sort()\n     return int(port_num) in portsinuse\n", "issue": "Run tests on windows and OSX\nPart of the reason we wanted tests with remote databases was to be able to test mindsdb on windows and OSX.\r\n\r\nThis is currently being done for native but not for mindsdb,  current issues that stop us from testing on OSX and windows:\r\n\r\n* `psutil.net_connections` requires root privileges on osx/windows\r\n* `ssh` command will fail on windows\r\n* ??? \n", "before_files": [{"content": "import psutil\nimport time\n\n\ndef is_port_in_use(port_num):\n    portsinuse = []\n    conns = psutil.net_connections()\n    portsinuse = [x.laddr[1] for x in conns if x.status == 'LISTEN']\n    portsinuse.sort()\n    return int(port_num) in portsinuse\n\n\ndef wait_func_is_true(func, timeout, *args, **kwargs):\n    start_time = time.time()\n\n    result = func(*args, **kwargs)\n    while result is False and (time.time() - start_time) < timeout:\n        time.sleep(2)\n        result = func(*args, **kwargs)\n\n    return result\n\n\ndef wait_port(port_num, timeout):\n    return wait_func_is_true(func=is_port_in_use, timeout=timeout, port_num=port_num)\n\n\ndef get_listen_ports(pid):\n    try:\n        p = psutil.Process(pid)\n        cons = p.connections()\n        cons = [x.laddr.port for x in cons]\n    except Exception:\n        return []\n    return cons\n\n\ndef is_pid_listen_port(pid, port):\n    ports = get_listen_ports(pid)\n    return int(port) in ports\n", "path": "mindsdb/utilities/ps.py"}], "after_files": [{"content": "import sys\nimport time\nfrom collections import namedtuple\nimport psutil\n\n\ndef net_connections():\n    \"\"\"Cross-platform psutil.net_connections like interface\"\"\"\n    if sys.platform.lower().startswith('linux'):\n        return psutil.net_connections()\n\n    all_connections = []\n    Pconn = None\n    for p in psutil.process_iter(['pid']):\n        try:\n            process = psutil.Process(p.pid)\n            connections = process.connections()\n            if connections:\n                for conn in connections:\n                    # Adding pid to the returned instance\n                    # for consistency with psutil.net_connections()\n                    if Pconn is None:\n                        fields = list(conn._fields)\n                        fields.append('pid')\n                        _conn = namedtuple('Pconn', fields)\n                    for attr in conn._fields:\n                        setattr(_conn, attr, getattr(conn, attr))\n                    _conn.pid = p.pid\n                    all_connections.append(_conn)\n\n        except (psutil.AccessDenied, psutil.ZombieProcess, psutil.NoSuchProcess):\n            pass\n    return all_connections\n\n\ndef is_port_in_use(port_num):\n    \"\"\"Check does any of child process uses specified port.\"\"\"\n    parent_process = psutil.Process()\n    child_pids = [x.pid for x in parent_process.children(recursive=True)]\n    conns = net_connections()\n    portsinuse = [x.laddr[1] for x in conns if x.pid in child_pids and x.status == 'LISTEN']\n    portsinuse.sort()\n    return int(port_num) in portsinuse\n\n\ndef wait_func_is_true(func, timeout, *args, **kwargs):\n    start_time = time.time()\n\n    result = func(*args, **kwargs)\n    while result is False and (time.time() - start_time) < timeout:\n        time.sleep(2)\n        result = func(*args, **kwargs)\n\n    return result\n\n\ndef wait_port(port_num, timeout):\n    return wait_func_is_true(func=is_port_in_use, timeout=timeout, port_num=port_num)\n\n\ndef get_listen_ports(pid):\n    try:\n        p = psutil.Process(pid)\n        cons = p.connections()\n        cons = [x.laddr.port for x in cons]\n    except Exception:\n        return []\n    return cons\n\n\ndef is_pid_listen_port(pid, port):\n    ports = get_listen_ports(pid)\n    return int(port) in ports\n", "path": "mindsdb/utilities/ps.py"}]}