Skip to content

Commit b86c1e6

Browse files
committed
PYTHON-1482 Fix monotonic time import for Python 2
Add changelog for 3.6.1
1 parent 251df6a commit b86c1e6

File tree

3 files changed

+68
-2
lines changed

3 files changed

+68
-2
lines changed

doc/changelog.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,29 @@
11
Changelog
22
=========
33

4+
Changes in Version 3.6.1
5+
------------------------
6+
7+
Version 3.6.1 fixes bugs reported since the release of 3.6.0:
8+
9+
- Fix regression in PyMongo 3.5.0 that causes idle sockets to be closed every
10+
second when ``maxIdleTimeMS`` is set. Idle sockets are now closed after
11+
``maxIdleTimeMS`` milliseconds.
12+
- :attr:`pymongo.mongo_client.MongoClient.max_idle_time_ms` returns
13+
milliseconds instead of seconds.
14+
- Properly import and use the
15+
`monotonic <https://pypi.python.org/pypi/monotonic>`_
16+
library for monotonic time when it is installed.
17+
18+
Issues Resolved
19+
...............
20+
21+
See the `PyMongo 3.6.1 release notes in JIRA`_ for the list of resolved issues
22+
in this release.
23+
24+
.. _PyMongo 3.6.1 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=19438
25+
26+
427
Changes in Version 3.6.0
528
------------------------
629

pymongo/monotonic.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
"""Time. Monotonic if possible.
1616
"""
1717

18+
from __future__ import absolute_import
19+
1820
__all__ = ['time']
1921

2022
try:
@@ -25,11 +27,11 @@
2527
pass
2628

2729
try:
28-
# From https://pypi.python.org/pypi/monotinic.
30+
# From https://pypi.python.org/pypi/monotonic.
2931
from monotonic import monotonic as time
3032
except ImportError:
3133
try:
32-
# Monotime or Python 3.3+.
34+
# Monotime or Python 3.
3335
from time import monotonic as time
3436
except ImportError:
3537
# Not monotonic.

test/test_monotonic.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright 2018-present 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+
15+
"""Test the monotonic module."""
16+
17+
import sys
18+
19+
sys.path[0:0] = [""]
20+
21+
from pymongo.monotonic import time as pymongo_time
22+
23+
from test import unittest
24+
25+
26+
class TestMonotonic(unittest.TestCase):
27+
def test_monotonic_time(self):
28+
try:
29+
from monotonic import monotonic
30+
self.assertIs(monotonic, pymongo_time)
31+
except ImportError:
32+
if sys.version_info[:2] >= (3, 3):
33+
from time import monotonic
34+
self.assertIs(monotonic, pymongo_time)
35+
else:
36+
from time import time
37+
self.assertIs(time, pymongo_time)
38+
39+
40+
if __name__ == "__main__":
41+
unittest.main()

0 commit comments

Comments
 (0)