Skip to main content

function callback

Project description

knocky

介绍

knocky包用于通信时帧头和帧正文处理解耦。

帧正文处理函数注册成knocky包的服务,帧头处理调用服务,调用knocky服务获取响应数据。

本软件包已上传到pypi,可输入命令直接安装。

pip install knocky

示例

import knocky as knock


def main():
    knock.register(0, 5, service1)
    print(knock.call(0, 5, bytearray([4, 5])))


def service1(req: bytearray, *args) -> (bytearray, bool):
    print('service1 get req:', req, args)
    return bytearray([1, 2, 3]), True


if __name__ == '__main__':
    main()

输出:

service1 get req: bytearray(b'\x04\x05') ()
resp: (bytearray(b'\x01\x02\x03'), True)

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

knocky-1.1.tar.gz (2.1 kB view details)

Uploaded Source

File details

Details for the file knocky-1.1.tar.gz.

File metadata

  • Download URL: knocky-1.1.tar.gz
  • Upload date:
  • Size: 2.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.7

File hashes

Hashes for knocky-1.1.tar.gz
Algorithm Hash digest
SHA256 d143f57fddfecd01009727b1b7d5bc637b845a730fae391e49c77a7654e9c6f8
MD5 f695291626e7dc30af8fc3107eaa49f4
BLAKE2b-256 4e477a9f304dd6e976293d8816310c52a8f2d085d5dde01c50795949a544929f

See more details on using hashes here.

Supported by

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