negtelnetserver.py: have it call its close() method

Closes #9894
This commit is contained in:
Stefan Eissing 2022-11-11 16:39:06 +01:00 committed by Daniel Stenberg
parent 5f8351aea3
commit 00ea0aaf46
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -66,9 +66,9 @@ def telnetserver(options):
# Need to set the allow_reuse on the class, not on the instance.
socketserver.TCPServer.allow_reuse_address = True
server = socketserver.TCPServer(local_bind, NegotiatingTelnetHandler)
with socketserver.TCPServer(local_bind, NegotiatingTelnetHandler) as server:
server.serve_forever()
# leaving `with` calls server.close() automatically
return ScriptRC.SUCCESS