跳转到主要内容

并发无关的套接字API

项目描述

connio

Pypi version

A python concurrency agnostic communication library.

传递一个URL到单个点API函数 connio.connection_for_url(),它将返回一个具有通用通用API的通信对象。

当处理通过串行线或TCP(未来还包括USB)使用简单REQ-REP通信协议(例如: SCPI)的仪器时很有用。

根据您提供的URL,请求的通信对象将转发到相应的 serialiosockio 库。

使用asyncio编写,支持不同的并发模型

  • asyncio
  • 经典阻塞API
  • 基于未来的API
  • Python 2兼容的阻塞API(对于那些仍然使用Python 2的人)

安装

在您喜欢的Python环境中

pip install connio

用法

import asyncio
from connio import connection_for_url

async def main():

    # A local async serial line
    sl = connection_for_url("serial:///dev/ttyS0", parity="E")
    print(await sl.write_readline(b"*IDN?\n"))

    # An async serial line over telnet server
    sl = connection_for_url("rfc2217://moxa.acme.org:7890", parity="E")
    print(await sl.write_readline(b"*IDN?\n"))

    # An async TCP connection
    tcp = connection_for_url("tcp://gepace.acme.org:5025")
    print(await tcp.write_readline(b"*IDN?\n"))

    # An sync TCP connection
    tcp = connection_for_url("tcp://gepace.acme.org:5025", concurrency="sync")
    print(tcp.write_readline(b"*IDN?\n"))

asyncio.run(main())

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码分发

connio-0.2.0.tar.gz (2.8 kB 查看哈希值)

上传时间 源代码

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面