auto.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/env python
  2. #
  3. # Copyright 2011 Facebook
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  6. # not use this file except in compliance with the License. You may obtain
  7. # a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  13. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  14. # License for the specific language governing permissions and limitations
  15. # under the License.
  16. """Implementation of platform-specific functionality.
  17. For each function or class described in `tornado.platform.interface`,
  18. the appropriate platform-specific implementation exists in this module.
  19. Most code that needs access to this functionality should do e.g.::
  20. from tornado.platform.auto import set_close_exec
  21. """
  22. from __future__ import absolute_import, division, print_function, with_statement
  23. import os
  24. if os.name == 'nt':
  25. from .common import Waker
  26. from .windows import set_close_exec
  27. else:
  28. from .posix import set_close_exec, Waker
  29. try:
  30. # monotime monkey-patches the time module to have a monotonic function
  31. # in versions of python before 3.3.
  32. import monotime
  33. except ImportError:
  34. pass
  35. try:
  36. from time import monotonic as monotonic_time
  37. except ImportError:
  38. monotonic_time = None