tonysimpson/nanomsg-python
Fork: 85 Star: 381 (更新于 2024-10-27 09:04:10)
license: MIT
Language: Python .
nanomsg wrapper for python with multiple backends (CPython and ctypes) should support 2/3 and Pypy
最后发布版本: 1.0 ( 2014-12-03 21:19:30)
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
最近版本更新:(数据更新于 2024-08-25 12:00:09)
2014-12-03 21:19:30 1.0
tonysimpson/nanomsg-python同语言 Python最近更新仓库
2024-11-14 21:11:52 LibraHp/GetQzonehistory
2024-11-14 08:17:54 langflow-ai/langflow
2024-11-14 06:52:29 ultralytics/ultralytics
2024-11-14 00:25:19 Huanshere/VideoLingo
2024-11-12 18:49:22 jxxghp/MoviePilot
2024-11-12 16:19:07 AnswerDotAI/rerankers