/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_ioloop.py (3965B)
# Copyright (C) PyZMQ Developers # Distributed under the terms of the Modified BSD License. from __future__ import absolute_import try: import asyncio except ImportError: asyncio = None import time import os import threading import pytest import zmq from zmq.tests import BaseZMQTestCase, have_gevent try: from tornado.ioloop import IOLoop as BaseIOLoop from zmq.eventloop import ioloop _tornado = True except ImportError: _tornado = False # tornado 5 with asyncio disables custom IOLoop implementations t5asyncio = False if _tornado: import tornado if tornado.version_info >= (5,) and asyncio: t5asyncio = True def printer(): os.system("say hello") raise Exception print (time.time()) class Delay(threading.Thread): def __init__(self, f, delay=1): self.f=f self.delay=delay self.aborted=False self.cond=threading.Condition() super(Delay, self).__init__() def run(self): self.cond.acquire() self.cond.wait(self.delay) self.cond.release() if not self.aborted: self.f() def abort(self): self.aborted=True self.cond.acquire() self.cond.notify() self.cond.release() class TestIOLoop(BaseZMQTestCase): if _tornado: IOLoop = ioloop.IOLoop def setUp(self): if not _tornado: pytest.skip("tornado required") super(TestIOLoop, self).setUp() if asyncio: asyncio.set_event_loop(asyncio.new_event_loop()) def tearDown(self): super(TestIOLoop, self).tearDown() BaseIOLoop.clear_current() BaseIOLoop.clear_instance() def test_simple(self): """simple IOLoop creation test""" loop = self.IOLoop() loop.make_current() dc = ioloop.PeriodicCallback(loop.stop, 200) pc = ioloop.PeriodicCallback(lambda : None, 10) pc.start() dc.start() t = Delay(loop.stop,1) t.start() loop.start() if t.is_alive(): t.abort() else: self.fail("IOLoop failed to exit") def test_instance(self): """IOLoop.instance returns the right object""" loop = self.IOLoop.instance() if not t5asyncio: assert isinstance(loop, self.IOLoop) base_loop = BaseIOLoop.instance() assert base_loop is loop def test_current(self): """IOLoop.current returns the right object""" loop = ioloop.IOLoop.current() if not t5asyncio: assert isinstance(loop, self.IOLoop) base_loop = BaseIOLoop.current() assert base_loop is loop def test_close_all(self): """Test close(all_fds=True)""" loop = self.IOLoop.current() req,rep = self.create_bound_pair(zmq.REQ, zmq.REP) loop.add_handler(req, lambda msg: msg, ioloop.IOLoop.READ) loop.add_handler(rep, lambda msg: msg, ioloop.IOLoop.READ) self.assertEqual(req.closed, False) self.assertEqual(rep.closed, False) loop.close(all_fds=True) self.assertEqual(req.closed, True) self.assertEqual(rep.closed, True) if have_gevent and _tornado: import zmq.green.eventloop.ioloop as green_ioloop class TestIOLoopGreen(TestIOLoop): IOLoop = green_ioloop.IOLoop def xtest_instance(self): """Green IOLoop.instance returns the right object""" loop = self.IOLoop.instance() if not t5asyncio: assert isinstance(loop, self.IOLoop) base_loop = BaseIOLoop.instance() assert base_loop is loop def xtest_current(self): """Green IOLoop.current returns the right object""" loop = self.IOLoop.current() if not t5asyncio: assert isinstance(loop, self.IOLoop) base_loop = BaseIOLoop.current() assert base_loop is loop