monotonic.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # Copyright 2014-2015 MongoDB, Inc.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. """Time. Monotonic if possible.
  15. """
  16. from __future__ import absolute_import
  17. __all__ = ['time']
  18. try:
  19. # Patches standard time module.
  20. # From https://pypi.python.org/pypi/Monotime.
  21. import monotime
  22. except ImportError:
  23. pass
  24. try:
  25. # From https://pypi.python.org/pypi/monotonic.
  26. from monotonic import monotonic as time
  27. except ImportError:
  28. try:
  29. # Monotime or Python 3.
  30. from time import monotonic as time
  31. except ImportError:
  32. # Not monotonic.
  33. from time import time