def test_specified_port(monkeypatch, context, ioc): pv, = context.get_pvs(ioc.pvs['float']) pv.wait_for_connection(timeout=10) circuit = pv.circuit_manager.circuit address_list = list(caproto.get_address_list()) address_list.append('{}:{}'.format(circuit.host, circuit.port)) def get_address_list(): return address_list for module in (caproto._utils, caproto, caproto.threading.client): if hasattr(module, 'get_address_list'): print('patching', module) monkeypatch.setattr(module, 'get_address_list', get_address_list) print() print('- address list is now:', address_list) shared_broadcaster = SharedBroadcaster() new_context = Context(shared_broadcaster) pv1, = new_context.get_pvs(ioc.pvs['float']) pv1.wait_for_connection() assert pv1.connected pv1.read() new_context.disconnect()
def context(request, shared_broadcaster): context = Context(broadcaster=shared_broadcaster) sb = shared_broadcaster yield context print('*** Cleaning up the context!') context.disconnect() assert not context._process_search_results_thread.is_alive() assert not context._activate_subscriptions_thread.is_alive() assert not context.selector.thread.is_alive() sb.disconnect() assert not sb._command_thread.is_alive() assert not sb.selector.thread.is_alive() assert not sb._retry_unanswered_searches_thread.is_alive()