Commit Graph

208 Commits

Author SHA1 Message Date
Michael Krasnyk 44b0230f84 Add missing return types. 2022-04-07 17:41:37 +02:00
Min RK 0c2772c320 deprecate utils.strtypes
let flake8 check F401, and fix some unused imports
2022-03-03 15:05:08 +01:00
wim glenn 819dbac75e Fix doc typos upd -> udp 2022-03-02 23:16:53 +11:00
Min RK b2199d6022 adopt myst, mdformat
- markdown for docs
- use mdformat to format markdown (way easier than prettier)

can't use colon_fenc with mdformat_myst yet
2022-03-02 10:02:10 +01:00
Min RK 2dc67d544c more types!
add annotations on more sugar methods, auth, devices

as well as proper types on most async wrappers
2022-01-11 15:49:04 +01:00
Min RK 7c024bad0a run pre-commit (isort, pyupgrade) 2021-12-07 14:44:16 +01:00
Min RK 7516fcfd7e
Merge pull request from minrk/constant-enum
use enums for constants
2021-12-07 10:39:38 +01:00
Min RK 70d11b6b0e use enums for constants
simple static declarations, rather than complex compile-time logic

no longer need separate tracking of socket option types either, can be tracked on SocketOption enum itself
2021-11-23 16:23:33 +01:00
Min RK 401f990ab9 add a few more types
in particular, sugar context methods (including private)
2021-11-05 10:59:50 +01:00
Min RK 4d2624f41b use weakref to avoid cyclic reference in `Frame.buffer`
this means `Frame.buffer` *may* be reconstructed if references to the cached value expire

Frame.buffer is also `memoryview(Frame)` instead of `memoryview(Frame.data)` which means it holds a reference to the Frame itself,
not a direct reference to the underlying data.
2021-08-10 11:50:59 +02:00
Min RK e0ffa7a55e remove unused rebuffer
we haven't compiled this module for some time, so it's just taking up space
2021-08-10 11:35:02 +02:00
Elliot Ronaghan 2c436b7cd5 Make memoryviews created from a Frame writeable with the cython backend
Previously, `Frame.buffer` or `memoryview(Frame)` would result in a
readonly view with the cython backend. This was originally done for
safety since concurrent sends and modifications of a Frame are unsafe.
e.g. if you modify data before a non-copying send is fully done you
would corrupt your message. However, modifying data before the send is
complete is a more general issue and making the view readonly only
protected the case where you're sending data you previously received,
but would not help when sending other arbitrary mutable data. See 1566
for more info.

Making the view writeable allows users to avoid a copy when doing things
like creating a mutable numpy array from a non-copying recv so this is
making a tradeoff between speed and a little bit of safety.

Resolves 1566
2021-07-29 10:31:38 -04:00
Elliot Ronaghan a92299e47a Fix memoryview support for the cffi backend
Previously, `__buffer__` was returning the raw `_buffer`, which isn't
always set. This resulted in `None` being returned, which caused type
errors about Frame not supporting the buffer interface. Switch to
returning `buffer`, which will set `_buffer` if it isn't already.

Part of 1566
2021-07-27 11:07:22 -04:00
Min RK fa95104474 nicer reprs for sockets, contexts
- <Socket(zmq.PUSH) at 0x...>
- <Context(2 sockets) at 0x...>

needs socket enum -> name reverse lookup
2021-07-24 12:08:32 +02:00
Christoph Gohlke c0d9e8ecf8
Fix conversion from 'zmq_fd_t' to 'int', possible loss of data 2021-05-25 07:50:04 -07:00
Christoph Gohlke 68c23ab91d
Use ZMQ_FD_T 2021-05-25 01:07:40 -07:00
Christoph Gohlke 063a19cdf0
Use ZMQ_FD_T 2021-05-25 01:06:54 -07:00
Christoph Gohlke 2ec798eee8
Use correct type and length for fd_sockopts in cffi backend on win_amd64 2021-05-24 20:51:01 -07:00
Christoph Gohlke ffd399f1ad
Use correct type for socket fd 2021-05-24 20:43:56 -07:00
Min RK d2011021c7 run pre-commit fixer 2021-05-16 21:23:37 +02:00
Tyler 819db43f2d
Fix license name (Lesser GNU GPL --> GNU Lesser GPL)
Just trying to satisfy the license classifiers out there - this license is actually named "GNU Lesser General Public License", not "Lesser GNU General Public License".
2021-02-16 10:11:05 -08:00
Min RK cbac3a5265 cffi: ensure Frame.bytes is bytes
it was previously `_data` which was a buffer for noncopying recvs
2021-01-28 14:45:06 +01:00
Min RK 02df348383
Merge pull request from minrk/better-external-libzmq
better support working with Windows releases of libzmq
2021-01-25 11:24:29 +00:00
arnimarj cfbcfe20f1 add py-typed 2021-01-23 13:55:56 +00:00
Min RK ca76ad0d82 specify default target Windows version
inherit Py_WIN_VER by default unless specified in extra macros

need to always load pyversion_compat for this to work
2021-01-22 15:53:13 +01:00
Dmitry Vinnik c6eb4c5032
Update __init__.pyi
https://pyzmq.readthedocs.io/en/latest/api/zmq.html#zmq.Socket.send
https://pyzmq.readthedocs.io/en/latest/api/zmq.html#zmq.Socket.recv
2021-01-22 12:43:17 +02:00
Min RK bc45c80de6 get zero-copy working on cffi
- use manual malloc/free as ffi.new has the wrong lifecycle
- implement zero-copy recv
- get buffer from zmq_msg
2021-01-13 14:59:05 +01:00
Min RK fd69d886b9 cffi: add some missing message-tracker attributes 2021-01-12 13:43:44 +01:00
Min RK 1b2520451f fix _cffi.lib import
it's called lib now
2021-01-12 13:43:44 +01:00
Min RK f138ed2225 split _cffi.c into its own file
- it's long enough that it's easier to be a standalone file
- load constant_names without zmq being importable
- address formatting, dropped py2compat
2021-01-12 13:43:44 +01:00
mattip f0104f9a86 use a proper cffi extension module, register for gc 2021-01-12 13:43:39 +01:00
mattip fe10b733c2 PyPy can make a pure python class support the buffer protocol 2021-01-12 13:43:05 +01:00
Min RK e20098de6d
Merge pull request from minrk/rm-py2compat
Remove some unused Python 2 compatibility
2020-11-27 13:08:50 +01:00
Min RK 97062eca76 remove various unreachable py2 conditions 2020-11-27 11:48:07 +01:00
Min RK 302080d2e1 remove sixcerpt py2compat
now that we can rely on `raise a from b`
2020-11-27 11:25:51 +01:00
Min RK a61563ee42 avoid deprecated cython syntax 2020-11-27 11:25:01 +01:00
Min RK 36ac1b6b22 update docs, example on using Frame for message property access 2020-11-26 09:53:48 +01:00
Min RK 4d9d025725 add mypy stubs
since this is a big change, take the opportunity to apply black, linters to code base
2020-11-25 15:16:34 +01:00
Min RK 552c0d837f
Merge pull request from minrk/require-python
Require Python >=3.5
2020-10-19 13:44:56 +02:00
Min RK fd03d371ca handle EFAULT in attrgetter
for context opts

and valid -1 return values (THREAD_SCHED_POLICY)
2020-10-16 11:28:44 +02:00
Min RK 52d2b2c539
Merge pull request from minrk/curve-keypair-gil
hold the gil while calling zmq_curve functions
2020-10-15 14:30:51 +02:00
Min RK 7ab15d5adb remove term/close from cython dealloc
auto close&term are implemented in `__del__` in sugar wrappers, which are more reliable when called

when `__del__` is skipped, e.g. in process teardown, don't trust dealloc to work as context may be deallocated before sockets

dealloc ordering makes things prone to hang on process teardown
2020-09-08 11:08:37 +02:00
Min RK 2cce2d354e hold the gil while calling zmq_curve functions
zmq source has some comments indicating pitfalls related to threadsafety

it appears to claim to have solved this with statics and locks (not sure),
but behavior suggests this may not be so.
2020-09-04 13:47:58 +02:00
Youhei Sakurai f3daa94ef7 Change a way to track sockets to WeakSet 2020-06-03 18:29:03 +09:00
Youhei Sakurai c22f72a3d5 Change a way to fix broken cffi backend on Windows 2020-05-13 10:35:24 +09:00
Youhei Sakurai 16f8449b85 Fix broken cffi backend due to sys/un.h on Windows 2020-03-18 13:52:33 +09:00
Min RK e3dfcce2f5 make zmq cimportable
- remove implicit relative imports
- backend/cython, devices no longer need to be on include path
- set language_level to 3str explicitly
- define zmq/__init__.pxd and zmq.backend.cython.__init__.pxd for package-level cimports
- test cython compilation with pyximport
2020-02-11 10:59:59 +01:00
Min RK 8c46215c06 move destroy to sugar context
to be shared by both Cython and cffi

fixes bugs in Cython implementation
2019-07-11 12:45:58 +02:00
Miguel Sánchez de León Peque 85a9e66f90 Display ipc path in case of ENOENT exception
Useful to see right in the traceback which ipc path caused the
exception.
2019-06-26 19:00:36 +02:00
Min RK 887f98151e docs coverage for new proxy apis 2019-02-19 11:15:56 +01:00