Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/zmq/backend/select.py: 71%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

14 statements  

1"""Import basic exposure of libzmq C API as a backend""" 

2 

3# Copyright (C) PyZMQ Developers 

4# Distributed under the terms of the Modified BSD License. 

5 

6from importlib import import_module 

7from typing import Dict 

8 

9public_api = [ 

10 'Context', 

11 'Socket', 

12 'Frame', 

13 'Message', 

14 'proxy', 

15 'proxy_steerable', 

16 'zmq_poll', 

17 'strerror', 

18 'zmq_errno', 

19 'has', 

20 'curve_keypair', 

21 'curve_public', 

22 'zmq_version_info', 

23 'IPC_PATH_MAX_LEN', 

24] 

25 

26 

27def select_backend(name: str) -> Dict: 

28 """Select the pyzmq backend""" 

29 try: 

30 mod = import_module(name) 

31 except ImportError: 

32 raise 

33 except Exception as e: 

34 raise ImportError(f"Importing {name} failed with {e}") from e 

35 ns = { 

36 # private API 

37 'monitored_queue': mod.monitored_queue, 

38 } 

39 ns.update({key: getattr(mod, key) for key in public_api}) 

40 return ns