MCPcopy Create free account
hub / github.com/bslatkin/effectivepython / run_server

Function run_server

example_code/item_076.py:229–242  ·  view source on GitHub ↗
(address)

Source from the content-addressed store, hash-verified

227 pass
228
229def run_server(address):
230 with socket.socket() as listener:
231 # Allow the port to be reused
232 listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
233 listener.bind(address)
234 listener.listen()
235 while True:
236 connection, _ = listener.accept()
237 thread = Thread(
238 target=handle_connection,
239 args=(connection,),
240 daemon=True,
241 )
242 thread.start()
243
244
245print("Example 14")

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected