/opt/imh-python/lib/python3.9/site-packages/zmq/tests
NameSizeModeActions
asyncio/-0755rm
__pycache__/-0755rm
conftest.py3660644editdlrm
test_auth.py207120644editdlrm
test_cffi_backend.py94810644editdlrm
test_constants.py45700644editdlrm
test_context.py120270644editdlrm
test_cython.py10480644editdlrm
test_decorators.py94950644editdlrm
test_device.py61690644editdlrm
test_draft.py14710644editdlrm
test_error.py12600644editdlrm
test_etc.py5250644editdlrm
test_future.py111590644editdlrm
test_imports.py18050644editdlrm
test_includes.py10130644editdlrm
test_ioloop.py39650644editdlrm
test_log.py66970644editdlrm
test_message.py110910644editdlrm
test_monitor.py30440644editdlrm
test_monqueue.py82230644editdlrm
test_multipart.py9440644editdlrm
test_pair.py12600644editdlrm
test_poll.py72600644editdlrm
test_proxy_steerable.py39220644editdlrm
test_pubsub.py10890644editdlrm
test_reqrep.py18410644editdlrm
test_retry_eintr.py29600644editdlrm
test_security.py81410644editdlrm
test_socket.py216530644editdlrm
test_ssh.py2340644editdlrm
test_version.py13340644editdlrm
test_win32_shim.py17410644editdlrm
test_z85.py22320644editdlrm
test_zmqstream.py24390644editdlrm
__init__.py63820644editdlrm
Edit: /opt/imh-python/lib/python3.9/site-packages/zmq/tests/test_retry_eintr.py (2960B)
# -*- coding: utf8 -*- # Copyright (C) PyZMQ Developers # Distributed under the terms of the Modified BSD License. import signal import time from threading import Thread from pytest import mark import zmq from zmq.tests import ( BaseZMQTestCase, SkipTest, skip_pypy ) from zmq.utils.strtypes import b # Partially based on EINTRBaseTest from CPython 3.5 eintr_tester class TestEINTRSysCall(BaseZMQTestCase): """ Base class for EINTR tests. """ # delay for initial signal delivery signal_delay = 0.1 # timeout for tests. Must be > signal_delay timeout = .25 timeout_ms = int(timeout * 1e3) def alarm(self, t=None): """start a timer to fire only once like signal.alarm, but with better resolution than integer seconds. """ if not hasattr(signal, 'setitimer'): raise SkipTest('EINTR tests require setitimer') if t is None: t = self.signal_delay self.timer_fired = False self.orig_handler = signal.signal(signal.SIGALRM, self.stop_timer) # signal_period ignored, since only one timer event is allowed to fire signal.setitimer(signal.ITIMER_REAL, t, 1000) def stop_timer(self, *args): self.timer_fired = True signal.setitimer(signal.ITIMER_REAL, 0, 0) signal.signal(signal.SIGALRM, self.orig_handler) @mark.skipif(not hasattr(zmq, 'RCVTIMEO'), reason="requires RCVTIMEO") def test_retry_recv(self): pull = self.socket(zmq.PULL) pull.rcvtimeo = self.timeout_ms self.alarm() self.assertRaises(zmq.Again, pull.recv) assert self.timer_fired @mark.skipif(not hasattr(zmq, 'SNDTIMEO'), reason="requires SNDTIMEO") def test_retry_send(self): push = self.socket(zmq.PUSH) push.sndtimeo = self.timeout_ms self.alarm() self.assertRaises(zmq.Again, push.send, b('buf')) assert self.timer_fired def test_retry_poll(self): x, y = self.create_bound_pair() poller = zmq.Poller() poller.register(x, zmq.POLLIN) self.alarm() def send(): time.sleep(2 * self.signal_delay) y.send(b('ping')) t = Thread(target=send) t.start() evts = dict(poller.poll(2 * self.timeout_ms)) t.join() assert x in evts assert self.timer_fired x.recv() def test_retry_term(self): push = self.socket(zmq.PUSH) push.linger = self.timeout_ms push.connect('tcp://127.0.0.1:5555') push.send(b('ping')) time.sleep(0.1) self.alarm() self.context.destroy() assert self.timer_fired assert self.context.closed def test_retry_getsockopt(self): raise SkipTest("TODO: find a way to interrupt getsockopt") def test_retry_setsockopt(self): raise SkipTest("TODO: find a way to interrupt setsockopt")