Details
-
Bug
-
Status: Backlog
-
Major - P3
-
Resolution: Unresolved
-
3.11
-
None
-
None
Description
Noticed this ResourceWarning for an unclosed socket while running the tests. The ResourceWarning seem to randomly occur throughout the test suite. The unclosed socket is created by the _RttMonitor added in PYTHON-2123. Here's an example:
$ python3 -X tracemalloc=25 setup.py test -s test.test_client
|
...
|
test_lazy_connect_w0 (test.test_client.TestClient) ... /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py:233: ResourceWarning: unclosed <socket.socket fd=19, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('127.0.0.1', 56306), raddr=('127.0.0.1', 27017)>
|
self._release_save = lock._release_save
|
Object allocated at (most recent call last):
|
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py", lineno 890
|
self._bootstrap_inner()
|
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py", lineno 932
|
self.run()
|
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py", lineno 870
|
self._target(*self._args, **self._kwargs)
|
File "/Users/shane/git/mongo-python-driver/pymongo/periodic_executor.py", lineno 125
|
if not self._target():
|
File "/Users/shane/git/mongo-python-driver/pymongo/monitor.py", lineno 46
|
monitor._run()
|
File "/Users/shane/git/mongo-python-driver/pymongo/monitor.py", lineno 369
|
rtt = self._ping()
|
File "/Users/shane/git/mongo-python-driver/pymongo/monitor.py", lineno 379
|
with self._pool.get_socket({}) as sock_info:
|
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/contextlib.py", lineno 113
|
return next(self.gen)
|
File "/Users/shane/git/mongo-python-driver/pymongo/pool.py", lineno 1225
|
sock_info = self._get_socket(all_credentials)
|
File "/Users/shane/git/mongo-python-driver/pymongo/pool.py", lineno 1275
|
sock_info = self.connect(all_credentials)
|
File "/Users/shane/git/mongo-python-driver/pymongo/pool.py", lineno 1180
|
sock = _configured_socket(self.address, self.opts)
|
File "/Users/shane/git/mongo-python-driver/pymongo/pool.py", lineno 988
|
sock = _create_connection(address, options)
|
File "/Users/shane/git/mongo-python-driver/pymongo/pool.py", lineno 950
|
sock = socket.socket(
|
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py:233: ResourceWarning: unclosed <socket.socket fd=32, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('127.0.0.1', 56324), raddr=('127.0.0.1', 27017)>
|
self._release_save = lock._release_save
|
Object allocated at (most recent call last):
|
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py", lineno 890
|
self._bootstrap_inner()
|
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py", lineno 932
|
self.run()
|
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py", lineno 870
|
self._target(*self._args, **self._kwargs)
|
File "/Users/shane/git/mongo-python-driver/pymongo/periodic_executor.py", lineno 125
|
if not self._target():
|
File "/Users/shane/git/mongo-python-driver/pymongo/monitor.py", lineno 46
|
monitor._run()
|
File "/Users/shane/git/mongo-python-driver/pymongo/monitor.py", lineno 369
|
rtt = self._ping()
|
File "/Users/shane/git/mongo-python-driver/pymongo/monitor.py", lineno 379
|
with self._pool.get_socket({}) as sock_info:
|
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/contextlib.py", lineno 113
|
return next(self.gen)
|
File "/Users/shane/git/mongo-python-driver/pymongo/pool.py", lineno 1225
|
sock_info = self._get_socket(all_credentials)
|
File "/Users/shane/git/mongo-python-driver/pymongo/pool.py", lineno 1275
|
sock_info = self.connect(all_credentials)
|
File "/Users/shane/git/mongo-python-driver/pymongo/pool.py", lineno 1180
|
sock = _configured_socket(self.address, self.opts)
|
File "/Users/shane/git/mongo-python-driver/pymongo/pool.py", lineno 988
|
sock = _create_connection(address, options)
|
File "/Users/shane/git/mongo-python-driver/pymongo/pool.py", lineno 950
|
sock = socket.socket(
|
ok
|
test_list_database_names (test.test_client.TestClient) ... ok
|
Here's an example from evergreen:
[2020/07/30 01:13:31.552] test_v2_db_aggregate_Aggregate_with_$listLocalSessions (test_crud_v2.TestSpec) ... /data/mci/1843e289f6ccf6880e33abf68b1877da/src/pymongo/periodic_executor.py:157: ResourceWarning: unclosed <socket.socket fd=11, family=AddressFamily.AF_INET, type=526337, proto=6, laddr=('127.0.0.1', 47305), raddr=('127.0.0.1', 27019)>
|
[2020/07/30 01:13:31.552] ref = weakref.ref(executor, _on_executor_deleted)
|
[2020/07/30 01:13:31.573] ok (0.098s)
|
Attachments
Issue Links
- is caused by
-
PYTHON-2123 Reduce Client Time To Recovery On Topology Changes
-
- Closed
-
- related to
-
PYTHON-3923 Handle socket closures in tests to avoid ResourceWarning
-
- Backlog
-
-
PYTHON-3917 [Build Failure] Fix handling of warnings in connection string tests
-
- Closed
-