MCPcopy Index your code
hub / github.com/RustPython/RustPython / run_client

Method run_client

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 8

lenFunction · 0.85
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