Skip to content

Commit d8f9a72

Browse files
authored
Merge pull request #82 from jepler/fix-failed-accept
Preserve the real error if accept failed.
2 parents 1fb9ee8 + 303adf8 commit d8f9a72

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

adafruit_httpserver/server.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ def poll(self) -> str:
399399
if self.stopped:
400400
raise ServerStoppedError
401401

402+
conn = None
402403
try:
403404
conn, client_address = self._sock.accept()
404405
conn.settimeout(self._timeout)
@@ -444,7 +445,8 @@ def poll(self) -> str:
444445
if self.debug:
445446
_debug_exception_in_handler(error)
446447

447-
conn.close()
448+
if conn is not None:
449+
conn.close()
448450
raise error # Raise the exception again to be handled by the user.
449451

450452
def require_authentication(self, auths: List[Union[Basic, Token, Bearer]]) -> None:

0 commit comments

Comments
 (0)