Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.10/site-packages/zmq/backend/__init__.py: 50%

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

20 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 

6import os 

7import platform 

8 

9from .select import public_api, select_backend 

10 

11if 'PYZMQ_BACKEND' in os.environ: 

12 backend = os.environ['PYZMQ_BACKEND'] 

13 if backend in ('cython', 'cffi'): 

14 backend = f'zmq.backend.{backend}' 

15 _ns = select_backend(backend) 

16else: 

17 # default to cython, fallback to cffi 

18 # (reverse on PyPy) 

19 if platform.python_implementation() == 'PyPy': 

20 first, second = ('zmq.backend.cffi', 'zmq.backend.cython') 

21 else: 

22 first, second = ('zmq.backend.cython', 'zmq.backend.cffi') 

23 

24 try: 

25 _ns = select_backend(first) 

26 except Exception as original_error: 

27 try: 

28 _ns = select_backend(second) 

29 except ImportError: 

30 raise original_error from None 

31 

32globals().update(_ns) 

33 

34__all__ = public_api