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

Class Connection

example_code/item_076.py:54–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52 pass
53
54class Connection:
55 def __init__(self, connection):
56 self.connection = connection
57 self.file = connection.makefile("rb")
58
59 def send(self, command):
60 line = command + "\n"
61 data = line.encode()
62 self.connection.send(data)
63
64 def receive(self):
65 line = self.file.readline()
66 if not line:
67 raise EOFError("Connection closed")
68 return line[:-1].decode()
69
70
71print("Example 2")

Callers 1

run_clientFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected