Use short-circuits and reindent to allow the single-line invocation of portend.occupied, required by older Pythons.
@@ -247,15 +247,16 @@ class ServerAdapter(object):
time.sleep(.1)
# Wait for port to be occupied
- if not os.environ.get('LISTEN_PID', None):
+ if os.environ.get('LISTEN_PID', None):
+ return
+
# Wait for port to be occupied if not running via socket-activation
# (for socket-activation the port will be managed by systemd )
- if isinstance(self.bind_addr, tuple):
+ if not isinstance(self.bind_addr, tuple):
+ return
+
with _safe_wait(*self.bound_addr):
- portend.occupied(
- *self.bound_addr,
- timeout=Timeouts.occupied,
- )
+ portend.occupied(*self.bound_addr, timeout=Timeouts.occupied)
@property
def bound_addr(self):
