ioloop.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. """ZAP Authenticator integrated with the tornado IOLoop.
  2. .. versionadded:: 14.1
  3. .. deprecated:: 25
  4. Use asyncio.AsyncioAuthenticator instead.
  5. Since tornado runs on asyncio, the asyncio authenticator
  6. offers the same functionality in tornado.
  7. """
  8. import warnings
  9. # Copyright (C) PyZMQ Developers
  10. # Distributed under the terms of the Modified BSD License.
  11. from typing import Any, Optional
  12. import zmq
  13. from .asyncio import AsyncioAuthenticator
  14. warnings.warn(
  15. "zmq.auth.ioloop.IOLoopAuthenticator is deprecated. Use zmq.auth.asyncio.AsyncioAuthenticator",
  16. DeprecationWarning,
  17. stacklevel=2,
  18. )
  19. class IOLoopAuthenticator(AsyncioAuthenticator):
  20. """ZAP authentication for use in the tornado IOLoop"""
  21. def __init__(
  22. self,
  23. context: Optional["zmq.Context"] = None,
  24. encoding: str = 'utf-8',
  25. log: Any = None,
  26. io_loop: Any = None,
  27. ):
  28. loop = None
  29. if io_loop is not None:
  30. warnings.warn(
  31. f"{self.__class__.__name__}(io_loop) is deprecated and ignored",
  32. DeprecationWarning,
  33. stacklevel=2,
  34. )
  35. loop = io_loop.asyncio_loop
  36. super().__init__(context=context, encoding=encoding, log=log, loop=loop)
  37. __all__ = ['IOLoopAuthenticator']