Skip to main content

deepfos系统使用的unix socket协议

Project description

客户端调用测试用例

async def async_main():
    loop = asyncio.get_running_loop()
    m = EchoClientProtocol("../unix_sock.sock", loop)
    await m.create_conn() # 建立一个连接
    await m.send_msg("O", "hello")
    
    await m.send_msg("O", "hello2")
    await m.close()
    # await m.send_msg("O", "hello3")

asyncio.run(async_main())

服务端自定义逻辑测试用例

''' protocol可以支持到让我在server端加入自定义逻辑, 比如可以传一个object, 这个object有dispatch方法, 每次你parse完,调这个dispatch,把mtype和解析结果传进去, 在其中我写自己定制化的逻辑 '''

class A:
    
    def print_data(self, mtype, data, **kwargs):
        print(mtype)
        print(data)

def a(mtype, data, **kwargs):
    print("mtype:", mtype)
    print("data:", data)
    print("kwargs:", kwargs)

m = MyServer(SOCK_FILE, ins=A, func="print_data", a=1, b=2)
m = MyServer(SOCK_FILE, ins=a, a="a", b="b")
m.run()

''' 第一个参数为sock文件位置 之后的参数都是可选参数 当ins参数为类对象时,后面必须带一个func参数,值为类下的方法名 无论使用类方法还是直接使用函数必须增加两个参数位置参数,mtype和data '''

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deepfos-ipc-protocol-0.0.9.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

deepfos_ipc_protocol-0.0.9-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file deepfos-ipc-protocol-0.0.9.tar.gz.

File metadata

  • Download URL: deepfos-ipc-protocol-0.0.9.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.2

File hashes

Hashes for deepfos-ipc-protocol-0.0.9.tar.gz
Algorithm Hash digest
SHA256 4b003de52ea707dc38f74e34ffcfdcb8c78fcd58b32d66801e1cdcc0bd1b604b
MD5 59326ce762858ce883fb6344b61b01d5
BLAKE2b-256 fd5cb1eec55dbc2dee6b0ebbe6c2f35f7c148fb46ffa5db908f93263edc3ccf6

See more details on using hashes here.

File details

Details for the file deepfos_ipc_protocol-0.0.9-py3-none-any.whl.

File metadata

File hashes

Hashes for deepfos_ipc_protocol-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 86038edc52a0a3f845d0fdcb1471bbd6146d39a6d60fec6f5d3ac93d52bad7f5
MD5 5cbfe017024b87110d90ad49f1040de7
BLAKE2b-256 a7ff876f970c5e4c3c6559ff6b6309bd5a0e948e9bf6c980efc444a171e02351

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page