Skip to content

Fix read forever loop - #15

Open
iivanov-qb wants to merge 8 commits into
masterfrom
fix-read-forever-loop
Open

Fix read forever loop#15
iivanov-qb wants to merge 8 commits into
masterfrom
fix-read-forever-loop

Conversation

@iivanov-qb

Copy link
Copy Markdown
Contributor
  • Fix read_forever loop
  • Migrate to uv
  • Add github action to run the tests
  • Fix handle_authentication interface mismatch
  • Fix get_event_loop on newer python versions
  • Drop deprecated ZMQEventLoop usage
  • Various minor test fixes
  • Cleanup socket leftovers after tests

The task is the only consumer of the socket and any non-handled
exception would kill the task and cut off every peer.

Catch all exceptions and let all BaseException subclasses escape: Those
are CancelledError, SystemExit, etc.
Replace msgpack-python with msgpack. We now rely on msgpack>=1 as we
don't provide the encoding argument anymore.

Add github action to run the tests as well.
The interface wrongly declared self as an explicit parameter,
unlike every sibling method, which made zope.interface.verifyClass
reject even backends that implemented it correctly. Also add the
missing no-op implementation to the trivial backends that don't
need the two-step auth challenge flow.
asyncio.get_event_loop() now raises instead of auto-creating a
loop when none is running or set, breaking any caller that builds
a Client/Server without passing loop= explicitly. Catch that and
fall back to creating and setting a new loop, matching the old
behavior.
zmq.asyncio.install() and a custom ZMQEventLoop fixture are no
longer needed: pyzmq 17+ sockets work with any standard asyncio
loop. Keeping them also broke tests, since pytest-asyncio stopped
honoring a same-named event_loop fixture override, so async tests
ran on a different loop than the one handed to Client/Server.

Replace the shared loop fixture with one that returns the loop
pytest-asyncio is actually driving, and give test_sync_client.py
its own sync fixture, since those tests aren't async.
- test_basic_heartbeating: widen the sleep window from 1.1s to 2s.
  ~0.5s of unavoidable PLAIN auth + PUB/SUB slow-joiner startup
  latency was eating into the original window, leaving too little
  steady-state time for 10 heartbeats at .1s apart to land.
- test_packer_translation: update a hardcoded packed-bytes literal.
  Current msgpack picks the more compact fixext4 form for this
  4-byte ext payload instead of the general ext8 form; same value,
  round-trips fine, the test just asserted stale exact bytes. Not
  a client/server compatibility issue: verified old msgpack-python
  and current msgpack decode each other's output byte-for-byte.
- test_job_server_never_reply: fix a str/bytes mismatch left over
  from very old code. The zmq delimiter frame is always bytes, and
  Packer.unpackb decodes str fields back to str, not bytes.
ipc:// endpoints bind a real unix socket file on disk, and closing
the socket doesn't unlink it. Several tests bind relative, bare
names (e.g. 'ipc://here'), which land in the cwd pytest runs from
and were piling up uncommitted in the repo root.

Add an autouse fixture that snapshots the cwd before each test and
removes any newly created socket files after it.
Includes:
* Fix read_forever loop
* Migrate to uv
* Add github action to run the tests
* Fix handle_authentication interface mismatch
* Fix get_event_loop on newer python versions
* Drop deprecated ZMQEventLoop usage
* Various minor test fixes
* Cleanup socket leftovers after tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant