MCPcopy Create free account
hub / github.com/ElementsProject/lightning / wait_connection

Function wait_connection

tests/plugins/slow_start.py:14–30  ·  view source on GitHub ↗
(request, plugin)

Source from the content-addressed store, hash-verified

12
13@plugin.async_method('waitconn')
14def wait_connection(request, plugin):
15 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
16 sock.bind(('localhost', 0))
17 sock.listen(1)
18 print("listening for connections on port {}".format(sock.getsockname()[1]))
19
20 # We are a one and done socket connection!
21 conn, client_addr = sock.accept()
22 try:
23 print("connection from {}".format(client_addr))
24 time.sleep(3)
25
26 finally:
27 conn.close()
28
29 print("closing socket")
30 sock.close()
31
32
33plugin.run()

Callers

nothing calls this directly

Calls 2

acceptMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected