8000 Failed connection counter reset by taybin · Pull Request #385 · encode/databases · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Failed connection counter reset #385

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 6 commits into from
Sep 10, 2021
Merged

Failed connection counter reset #385

merged 6 commits into from
Sep 10, 2021

Conversation

taybin
Copy link
Contributor
@taybin taybin commented Sep 9, 2021

This adds a unittest for #283. It does require the library asyncmock as AsyncMock isn't available in python 3.6 or 3.7 yet. If testing on 3.6 and 3.6 is not a requirement, we can use unittest.mocks.AsyncMock since it's included in python 3.8.

@aminalaee

@taybin taybin changed the title Failed connection fix Failed connection counter reset Sep 9, 2021
@taybin
Copy link
Contributor Author
taybin commented Sep 9, 2021

I tried the test with and without the code fix and the test fails as expected without the _connection_counter rollback.

@aminalaee
Copy link
Member

@taybin Thanks for this. Can we remove asyncmock requirement with this?

class AsyncMock(MagicMock):
    async def __call__(self, *args, **kwargs):
        return super(AsyncMock, self).__call__(*args, **kwargs)

credit

@aminalaee
Copy link
Member
aminalaee commented Sep 9, 2021

@taybin I think the Exception("boo!") can be simplified to Exception() too. We're basically comparing generated exception with itself. We could have a more specific exception raised.

@taybin
Copy link
Contributor Author
taybin commented Sep 9, 2021

@aminalaee I wanted to be sure it was that specific Exception that was being caught. pytest.raises(Exception) will pass on any error and I wanted to avoid that. How's this change? (Removed the asyncmock dep too)

@aminalaee
Copy link
Member

@taybin I was thinking raising an exception like TimeoutError and comparing that instead of Exception. But I think what we already have is great. Thanks.

@aminalaee aminalaee merged commit 6fcb168 into encode:master Sep 10, 2021
@taybin taybin deleted the failed-connection-fix branch September 10, 2021 13:42
aminalaee added a commit that referenced this pull request Sep 11, 2021
Avoid dangling task-local connections after Database.disconnect() (#211)

Co-authored-by: Amin Alaee <mohammadamin.alaee@gmail.com>

Reset counter for failed connections (#385)

Co-authored-by: Sergey Morozov <sergey@morozov.top>

Version 0.5.2 (#386)

update requirements

change scripts

update pytest config

update pytest

Update requirements

update workflow

try cache in workflow

disable coverage for py3.6

use cache in env

fix workflow

cache keys

update coverage workflow

test

test again

test

use absoulte path
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.

3 participants
0