select.py 921 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. """Import basic exposure of libzmq C API as a backend"""
  2. # Copyright (C) PyZMQ Developers
  3. # Distributed under the terms of the Modified BSD License.
  4. public_api = [
  5. 'Context',
  6. 'Socket',
  7. 'Frame',
  8. 'Message',
  9. 'device',
  10. 'proxy',
  11. 'proxy_steerable',
  12. 'zmq_poll',
  13. 'strerror',
  14. 'zmq_errno',
  15. 'has',
  16. 'curve_keypair',
  17. 'curve_public',
  18. 'constants',
  19. 'zmq_version_info',
  20. 'IPC_PATH_MAX_LEN',
  21. ]
  22. def select_backend(name):
  23. """Select the pyzmq backend"""
  24. try:
  25. mod = __import__(name, fromlist=public_api)
  26. except ImportError:
  27. raise
  28. except Exception as e:
  29. import sys
  30. from zmq.utils.sixcerpt import reraise
  31. exc_info = sys.exc_info()
  32. reraise(ImportError, ImportError("Importing %s failed with %s" % (name, e)), exc_info[2])
  33. ns = {}
  34. for key in public_api:
  35. ns[key] = getattr(mod, key)
  36. return ns