Skip to content

Commit 102ec7d

Browse files
author
Johannes Otepka
committed
support of pymongo 4.x added
1 parent 180ef0a commit 102ec7d

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

ipyparallel/controller/mongodb.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""A TaskRecord backend using mongodb"""
22

33
try:
4+
from pymongo import version
45
from pymongo import MongoClient
56
except ImportError:
67
from pymongo import Connection as MongoClient
@@ -11,17 +12,14 @@
1112
except ImportError:
1213
from bson import Binary
1314

14-
# we need to determine the pymongo version because of API changes. see
15-
# https://pymongo.readthedocs.io/en/stable/migrate-to-pymongo4.html
16-
from importlib.metadata import version
17-
1815
from traitlets import Dict, Instance, List, Unicode
1916

2017
from .dictdb import BaseDB
2118

22-
MongoClientVersion = version('pymongo')
23-
pymongo_version_major = int(MongoClientVersion.split('.')[0])
24-
pymongo_version_minor = int(MongoClientVersion.split('.')[1])
19+
# we need to determine the pymongo version because of API changes. see
20+
# https://pymongo.readthedocs.io/en/stable/migrate-to-pymongo4.html
21+
pymongo_version_major = int(version.split('.')[0])
22+
pymongo_version_minor = int(version.split('.')[1])
2523

2624
# -----------------------------------------------------------------------------
2725
# MongoDB class

0 commit comments

Comments
 (0)