nanomsg-python

具有多个后端(CPython 和 ctypes)的 python nanomsg 包装器应该支持 2/3 和 Pypy。「nanomsg wrapper for python with multiple backends (CPython and ctypes) should support 2/3 and Pypy」

Github星跟踪图

nanomsg-python

Python library for nanomsg which does not compromise on
usability or performance.

Like nanomsg this library is still experimental, the API is fairly stable but
if you plan to use it at this time be prepared to get your hands dirty,
fixes and enhancements are very welcome.

The following versions of Python are supported CPython 2.6+, 3.2+ and Pypy 2.1.0+

Bugs and change requests can be made
here.

nanommsg library in /usr/local

If you're nanomsg is in /usr/local and your machine is not configured to find it there you can rename the usr_local_setup.cfg to setup.cfg to fix the problem.

Example

from __future__ import print_function
from nanomsg import Socket, PAIR, PUB
s1 = Socket(PAIR)
s2 = Socket(PAIR)
s1.bind('inproc://bob')
s2.connect('inproc://bob')
s1.send(b'hello nanomsg')
print(s2.recv())
s1.close()
s2.close()

Or if you don't mind nesting you can use Socket as a context manager

with Socket(PUB) as pub_socket:
    .... do something with pub_socket
# socket is closed

The lower level API is also available if you need the additional control or
performance, but it is harder to use. Error checking left out for brevity.

from nanomsg import wrapper as nn_wrapper
from nanomsg import PAIR, AF_SP

s1 = nn_wrapper.nn_socket(AF_SP, PAIR)
s2 = nn_wrapper.nn_socket(AF_SP, PAIR)
nn_wrapper.nn_bind(s1, 'inproc://bob')
nn_wrapper.nn_connect(s2, 'inproc://bob')
nn_wrapper.nn_send(s1, b'hello nanomsg', 0)
result, buffer = nn_wrapper.nn_recv(s2, 0)
print(bytes(buffer))
nn_wrapper.nn_term()

License

MIT

Authors

Tony Simpson

主要指标

概览
名称与所有者tonysimpson/nanomsg-python
主编程语言Python
编程语言C (语言数: 3)
平台Linux, Mac, Windows
许可证MIT License
所有者活动
创建于2013-08-21 12:52:49
推送于2021-08-13 08:15:22
最后一次提交2021-08-13 09:15:22
发布数1
最新版本名称1.0 (发布于 )
第一版名称1.0 (发布于 )
用户参与
星数383
关注者数30
派生数84
提交数101
已启用问题?
问题数50
打开的问题数33
拉请求数18
打开的拉请求数7
关闭的拉请求数8
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?