import socket import msgpack import struct import contextlib @contextlib.contextmanager def client(): with contextlib.closing(socket.socket()) as s: s.connect(('127.0.0.1', 10000)) yield s def _db_send(s, p): r = msgpack.dumps(p) s.send(struct.pack("