Skip to content
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

Hangs with pytest with 0.2.3 (Thread pb ?) #43

Open
marcdexet-cnrs opened this issue Jul 20, 2021 · 3 comments
Open

Hangs with pytest with 0.2.3 (Thread pb ?) #43

marcdexet-cnrs opened this issue Jul 20, 2021 · 3 comments
Assignees
Labels
bug Something isn't working testing Testing enhancements

Comments

@marcdexet-cnrs
Copy link

marcdexet-cnrs commented Jul 20, 2021

Switching from 0.2.2 to 0.2.3 makes mongo client hanging for closing.
Time go from 1s to 32 s for one test

To Reproduce

Run following test with 0.2.2 then 0.2.3 (pytest)

def test_mongo():

    with MongoClient() as client:
        # Given
        db = client['toolbox']
        tm : Collection = db.tm

        # When
        oid = tm.insert_one({'name': 'foo', 'kind': 'bar'}).inserted_id

        # Then
        assert oid is not None
        retrieved = tm.find_one({'_id': oid})
        assert retrieved is not None
        assert retrieved['name'] == 'foo'

        # When
        tm.delete_one({'_id': oid})
        assert tm.find_one({'_id': oid}) is None

Expected behavior
Avoid hanging

Logs
0.2.2

time pytest tests/unit/persistance/test_inmemory_mongo.py 
=============================================================================================== test session starts ===============================================================================================
platform linux -- Python 3.8.10, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: /home/cram/Workdir/IAS/MAJIS/majis_tm_toolbox, configfile: pytest.ini
plugins: mock-3.6.1, integration-0.2.2
collected 1 item                                                                                                                                                                                                  

tests/unit/persistance/test_inmemory_mongo.py::test_mongo 
-------------------------------------------------------------------------------------------------- live log call --------------------------------------------------------------------------------------------------
WARNING  PYMONGOIM_DOWNLOADER:__init__.py:214 Starting from MongoDB 4.0.23 there isn't a generic Linux version of MongoDB
PASSED                                                                                                                                                                                                      [100%]

================================================================================================ warnings summary =================================================================================================
tests/unit/persistance/test_inmemory_mongo.py::test_mongo
  /home/cram/Workdir/IAS/MAJIS/majis_tm_toolbox/.venv/lib/python3.8/site-packages/pymongo_inmemory/downloader/__init__.py:214: DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead
    logger.warn((

-- Docs: https://docs.pytest.org/en/stable/warnings.html
========================================================================================== 1 passed, 1 warning in 0.44s ===========================================================================================

real	0m1,460s
user	0m1,004s
sys	0m0,634s
(majis_tm_toolbox) cram@cram-Precision-M6800:~/Workdir/IAS/MAJIS/majis_tm_toolbox$ 

0.2.3

time pytest tests/unit/persistance/test_inmemory_mongo.py 
=============================================================================================== test session starts ===============================================================================================
platform linux -- Python 3.8.10, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: /home/cram/Workdir/IAS/MAJIS/majis_tm_toolbox, configfile: pytest.ini
plugins: mock-3.6.1, integration-0.2.2
collected 1 item                                                                                                                                                                                                  

tests/unit/persistance/test_inmemory_mongo.py::test_mongo 
-------------------------------------------------------------------------------------------------- live log call --------------------------------------------------------------------------------------------------
WARNING  PYMONGOIM_DOWNLOADER:__init__.py:191 Starting from MongoDB 4.0.23 there isn't a generic Linux version of MongoDB
PASSED                                                                                                                                                                                                      [100%]

================================================================================================ warnings summary =================================================================================================
tests/unit/persistance/test_inmemory_mongo.py::test_mongo
  /home/cram/Workdir/IAS/MAJIS/majis_tm_toolbox/.venv/lib/python3.8/site-packages/pymongo_inmemory/downloader/__init__.py:191: DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead
    logger.warn((

-- Docs: https://docs.pytest.org/en/stable/warnings.html
========================================================================================== 1 passed, 1 warning in 31.84s ==========================================================================================

real	0m32,818s
user	0m1,541s
sys	0m0,499s

Screenshots
Profiles generated with pycharm profilings tools

With 0_2_2
0_2_2

With 0_2_3
0_2_3

Context:

  • OS: Linux Ubuntu
  • Version of pymongo_inmemory 0.2.3
  • Version of mongo you are downloading 4.0.3
  • Any other additional information about context
@marcdexet-cnrs marcdexet-cnrs added the bug Something isn't working label Jul 20, 2021
@ekarademir ekarademir added the testing Testing enhancements label Jul 31, 2021
@ekarademir ekarademir self-assigned this Jul 31, 2021
@ekarademir
Copy link
Collaborator

Hi @marcdexet-cnrs I'm looking into this, but unfortunately I can't give a certain timeframe to resolve this. In th emean time if you figure it out please feel free to submit a PR.

@leonardoleanodev
Copy link

Looking for the stacktrace into the log it does not generated an error, but a deprecation from warn to warning? have you (@marcdexet-cnrs ) experienced any lock or other type of trouble running the test?

@ekarademir
Copy link
Collaborator

The mention above relates to the timeline on which I can look into this issue. I moved houses and still settling in so I don't have a proper setup to work on this yet. But I haven't forgotten about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working testing Testing enhancements
Projects
None yet
Development

No branches or pull requests

3 participants