Skip to content

Commit c9de630

Browse files
committed
Fix portability issues in Cluster
1 parent 2619929 commit c9de630

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

asyncpg/cluster.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,21 @@
99
import errno
1010
import os
1111
import os.path
12+
import platform
1213
import random
1314
import re
1415
import shutil
1516
import socket
1617
import subprocess
17-
import sys
1818
import tempfile
1919
import time
2020

2121
import asyncpg
2222

2323

24-
class ClusterError(Exception):
25-
pass
24+
_system = platform.uname().system
2625

27-
if sys.platform == 'linux':
26+
if _system == 'Linux':
2827
def ensure_dead_with_parent():
2928
import ctypes
3029
import signal
@@ -36,8 +35,7 @@ def ensure_dead_with_parent():
3635
except Exception as e:
3736
print(e)
3837
else:
39-
def ensure_dead_with_parent():
40-
pass
38+
ensure_dead_with_parent = None
4139

4240

4341
def find_available_port(port_range=(49152, 65535), max_tries=1000):
@@ -65,6 +63,10 @@ def find_available_port(port_range=(49152, 65535), max_tries=1000):
6563
return port
6664

6765

66+
class ClusterError(Exception):
67+
pass
68+
69+
6870
class Cluster:
6971
def __init__(self, data_dir, *, pg_config_path=None):
7072
self._data_dir = data_dir
@@ -88,7 +90,7 @@ def get_status(self):
8890
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
8991
stdout, stderr = process.stdout, process.stderr
9092

91-
if process.returncode == 4:
93+
if process.returncode == 4 or not os.listdir(self._data_dir):
9294
return 'not-initialized'
9395
elif process.returncode == 3:
9496
return 'stopped'

0 commit comments

Comments
 (0)