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