Skip to content

PYTHON-2334 Add regression test for gevent.Timeout compatibility #475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 30, 2020

Conversation

ShaneHarvey
Copy link
Member

This is a follow on to: #472

Before the fixes this test would fail like this:

======================================================================
ERROR: test_gevent_timeout (test.test_client.TestMongoClientFailover)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/shane/git/mongo-python-driver/test/test_client.py", line 1975, in test_gevent_timeout
    self.assertIsNone(ct.get())
  File "src/gevent/greenlet.py", line 769, in gevent._gevent_cgreenlet.Greenlet.get
  File "src/gevent/greenlet.py", line 364, in gevent._gevent_cgreenlet.Greenlet._raise_exception
  File "/Users/shane/git/mongo-python-driver/venv3.8/lib/python3.8/site-packages/gevent/_compat.py", line 65, in reraise
    raise value.with_traceback(tb)
  File "src/gevent/greenlet.py", line 854, in gevent._gevent_cgreenlet.Greenlet.run
  File "/Users/shane/git/mongo-python-driver/test/test_client.py", line 1959, in contentious_task
    coll.find_one({'$where': delay(1)})
  File "/Users/shane/git/mongo-python-driver/pymongo/collection.py", line 1319, in find_one
    for result in cursor.limit(-1):
  File "/Users/shane/git/mongo-python-driver/pymongo/cursor.py", line 1207, in next
    if len(self.__data) or self._refresh():
  File "/Users/shane/git/mongo-python-driver/pymongo/cursor.py", line 1124, in _refresh
    self.__send_message(q)
  File "/Users/shane/git/mongo-python-driver/pymongo/cursor.py", line 999, in __send_message
    response = client._run_operation_with_response(
  File "/Users/shane/git/mongo-python-driver/pymongo/mongo_client.py", line 1368, in _run_operation_with_response
    return self._retryable_read(
  File "/Users/shane/git/mongo-python-driver/pymongo/mongo_client.py", line 1471, in _retryable_read
    return func(session, server, sock_info, slave_ok)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/contextlib.py", line 120, in __exit__
    next(self.gen)
  File "/Users/shane/git/mongo-python-driver/pymongo/mongo_client.py", line 1312, in _slaveok_for_server
    yield sock_info, slave_ok
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/contextlib.py", line 120, in __exit__
    next(self.gen)
  File "/Users/shane/git/mongo-python-driver/pymongo/mongo_client.py", line 1255, in _get_socket
    yield sock_info
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/contextlib.py", line 120, in __exit__
    next(self.gen)
  File "/Users/shane/git/mongo-python-driver/pymongo/pool.py", line 1238, in get_socket
    self.return_socket(sock_info)
  File "/Users/shane/git/mongo-python-driver/pymongo/pool.py", line 1317, in return_socket
    self._socket_semaphore.release()
  File "/Users/shane/git/mongo-python-driver/pymongo/thread_util.py", line 86, in release
    return Semaphore.release(self)
  File "/Users/shane/git/mongo-python-driver/pymongo/thread_util.py", line 64, in release
    self._cond.acquire()
  File "/Users/shane/git/mongo-python-driver/venv3.8/lib/python3.8/site-packages/gevent/thread.py", line 118, in acquire
    acquired = BoundedSemaphore.acquire(self, blocking, timeout)
  File "src/gevent/_semaphore.py", line 143, in gevent._gevent_c_semaphore.Semaphore.acquire
  File "src/gevent/_semaphore.py", line 178, in gevent._gevent_c_semaphore.Semaphore.acquire
  File "src/gevent/_abstract_linkable.py", line 381, in gevent._gevent_c_abstract_linkable.AbstractLinkable._wait
  File "src/gevent/_abstract_linkable.py", line 346, in gevent._gevent_c_abstract_linkable.AbstractLinkable._wait_core
  File "src/gevent/_abstract_linkable.py", line 352, in gevent._gevent_c_abstract_linkable.AbstractLinkable._wait_core
  File "src/gevent/_abstract_linkable.py", line 348, in gevent._gevent_c_abstract_linkable.AbstractLinkable._wait_core
  File "src/gevent/_abstract_linkable.py", line 303, in gevent._gevent_c_abstract_linkable.AbstractLinkable._AbstractLinkable__wait_to_be_notified
  File "src/gevent/_greenlet_primitives.py", line 61, in gevent._gevent_c_greenlet_primitives.SwitchOutGreenletWithLoop.switch
  File "src/gevent/_greenlet_primitives.py", line 61, in gevent._gevent_c_greenlet_primitives.SwitchOutGreenletWithLoop.switch
  File "src/gevent/_greenlet_primitives.py", line 65, in gevent._gevent_c_greenlet_primitives.SwitchOutGreenletWithLoop.switch
  File "src/gevent/_gevent_c_greenlet_primitives.pxd", line 35, in gevent._gevent_c_greenlet_primitives._greenlet_switch
gevent.timeout.Timeout: 10 seconds

----------------------------------------------------------------------
Ran 1 test in 10.015s

FAILED (errors=1)

After the changes in PYTHON-2334 the test passes.

CC: @TylerWilley

Copy link
Contributor

@prashantmital prashantmital left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. LGTM

@ShaneHarvey
Copy link
Member Author

ShaneHarvey commented Jul 30, 2020

This is blocked on the 3.6+ sharded cluster test failures:

 [2020/07/29 23:37:12.266] ERROR [20.041s]: test_send_hedge (test_read_preferences.TestMongosAndReadPreference)
 [2020/07/29 23:37:12.266] ----------------------------------------------------------------------
 [2020/07/29 23:37:12.266] Traceback (most recent call last):
 [2020/07/29 23:37:12.266]   File "/data/mci/720718fde188c25a0d53d0b1c1d3de80/src/test/__init__.py", line 444, in wrap
 [2020/07/29 23:37:12.266]     return f(*args, **kwargs)
 [2020/07/29 23:37:12.266]   File "/data/mci/720718fde188c25a0d53d0b1c1d3de80/src/test/test_read_preferences.py", line 632, in test_send_hedge
 [2020/07/29 23:37:12.266]     coll.find_one()
 [2020/07/29 23:37:12.266]   File "/data/mci/720718fde188c25a0d53d0b1c1d3de80/src/pymongo/collection.py", line 1319, in find_one
 [2020/07/29 23:37:12.266]     for result in cursor.limit(-1):
 [2020/07/29 23:37:12.266]   File "/data/mci/720718fde188c25a0d53d0b1c1d3de80/src/pymongo/cursor.py", line 1207, in next
 [2020/07/29 23:37:12.266]     if len(self.__data) or self._refresh():
 [2020/07/29 23:37:12.266]   File "/data/mci/720718fde188c25a0d53d0b1c1d3de80/src/pymongo/cursor.py", line 1124, in _refresh
 [2020/07/29 23:37:12.266]     self.__send_message(q)
 [2020/07/29 23:37:12.266]   File "/data/mci/720718fde188c25a0d53d0b1c1d3de80/src/pymongo/cursor.py", line 1001, in __send_message
 [2020/07/29 23:37:12.266]     address=self.__address)
 [2020/07/29 23:37:12.266]   File "/data/mci/720718fde188c25a0d53d0b1c1d3de80/src/pymongo/mongo_client.py", line 1372, in _run_operation_with_response
 [2020/07/29 23:37:12.266]     exhaust=exhaust)
 [2020/07/29 23:37:12.266]   File "/data/mci/720718fde188c25a0d53d0b1c1d3de80/src/pymongo/mongo_client.py", line 1471, in _retryable_read
 [2020/07/29 23:37:12.266]     return func(session, server, sock_info, slave_ok)
 [2020/07/29 23:37:12.266]   File "/data/mci/720718fde188c25a0d53d0b1c1d3de80/src/pymongo/mongo_client.py", line 1366, in _cmd
 [2020/07/29 23:37:12.266]     unpack_res)
 [2020/07/29 23:37:12.267]   File "/data/mci/720718fde188c25a0d53d0b1c1d3de80/src/pymongo/server.py", line 137, in run_operation_with_response
 [2020/07/29 23:37:12.267]     first, sock_info.max_wire_version)
 [2020/07/29 23:37:12.267]   File "/data/mci/720718fde188c25a0d53d0b1c1d3de80/src/pymongo/helpers.py", line 168, in _check_command_response
 [2020/07/29 23:37:12.267]     max_wire_version)
 [2020/07/29 23:37:12.267] pymongo.errors.OperationFailure: Encountered non-retryable error during query :: caused by :: Could not find host matching read preference { mode: "secondary", hedge: { enabled: true } } for set 2b0c4068-ce33-4281-b57e-f67ce1ce77ed, full error: {'ok': 0.0, 'errmsg': 'Encountered non-retryable error during query :: caused by :: Could not find host matching read preference { mode: "secondary", hedge: { enabled: true } } for set 2b0c4068-ce33-4281-b57e-f67ce1ce77ed', 'code': 133, 'codeName': 'FailedToSatisfyReadPreference', '$clusterTime': {'clusterTime': Timestamp(1596065694, 1), 'signature': {'hash': b'vs_\xdb\x0b\xab\xf8\xe6\xbbG\xaa<\xba,\xa2\xc9\xde\xa5\xdc\xb0', 'keyId': 6855047922183045142}}, 'operationTime': Timestamp(1596065694, 1)}
 [2020/07/29 23:37:12.499] ----------------------------------------------------------------------

@ShaneHarvey ShaneHarvey merged commit c99254f into mongodb:master Jul 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants