MCPcopy Index your code
hub / github.com/python/cpython / run_client

Method run_client

Lib/test/test_socketserver.py:435–455  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

433 main_thread = threading.get_ident()
434
435 def run_client():
436 s = socket.socket(server.address_family, socket.SOCK_STREAM,
437 socket.IPPROTO_TCP)
438 with s, s.makefile('rb') as reader:
439 s.connect(server.server_address)
440 nonlocal response1
441 response1 = reader.readline()
442 s.sendall(b'client response\n')
443
444 reader.read(100)
445 # The main thread should now be blocking in a send() syscall.
446 # But in theory, it could get interrupted by other signals,
447 # and then retried. So keep sending the signal in a loop, in
448 # case an earlier signal happens to be delivered at an
449 # inconvenient moment.
450 while True:
451 pthread_kill(main_thread, signal.SIGUSR1)
452 if interrupted.wait(timeout=float(1)):
453 break
454 nonlocal received2
455 received2 = len(reader.read())
456
457 background = threading.Thread(target=run_client)
458 background.start()

Callers

nothing calls this directly

Calls 7

socketMethod · 0.80
makefileMethod · 0.45
connectMethod · 0.45
readlineMethod · 0.45
sendallMethod · 0.45
readMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected