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

Support python 3.7 and 3.8 in travis CI #493

Merged

Conversation

MateuszCzubak
Copy link
Contributor

@MateuszCzubak MateuszCzubak commented May 28, 2020

  • Fix tests to pass on python 3.7 and 3.8 versions
  • Support python 3.7 and 3.8 in Travis CI

@codecov

This comment has been minimized.

@MateuszCzubak MateuszCzubak force-pushed the support-python-3.7-and-3.8-in-travis branch 6 times, most recently from 3d2b1c9 to e2064b7 Compare May 28, 2020 14:44
@MateuszCzubak
Copy link
Contributor Author

@terrycain @webknjaz can you please take a look? Hopefully these changes will make possible to release the next version.

@MateuszCzubak MateuszCzubak force-pushed the support-python-3.7-and-3.8-in-travis branch from 0240e2a to 95aeac5 Compare May 28, 2020 15:09
@@ -131,7 +131,7 @@ async def test_create_pool_deprecations(mysql_params, loop):
warnings.simplefilter("always")
async with pool.get() as conn:
pass
assert issubclass(w[-1].category, DeprecationWarning)
assert issubclass(w[0].category, DeprecationWarning)
Copy link
Member

Choose a reason for hiding this comment

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

Why is this important?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is necessary for tests to pass on P3.7 with PYTHONASYNCIODEBUG=1, for which there are two warnings emitted:

(Pdb) print([x.category for x in w])
[<class 'DeprecationWarning'>, <class 'ResourceWarning'>]

It doesn't happen on P3.8 though. Here's related build result:
https://travis-ci.com/github/aio-libs/aiomysql/jobs/341264313

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The ResourceWarning msg:

ResourceWarning('unclosed event loop <_UnixSelectorEventLoop running=False closed=False debug=True>')

coming from asyncio/base_events.py line 623 (def __del__(self))

Copy link
Member

Choose a reason for hiding this comment

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

Okay, in this case, we should add a code comment explaining this magic of choosing which element to compare.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added a code comment. I have also added some explanation in the commit msg.

Copy link
Member

Choose a reason for hiding this comment

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

Honestly that ResourceWarning is a bug that may mean that our tests don't close the loop properly, upon teardown. Does this happen under Python 3.8?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, this happens only under 3.7

tests/test_async_with.py Outdated Show resolved Hide resolved
Copy link
Member

@webknjaz webknjaz left a comment

Choose a reason for hiding this comment

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

Looks like this pulls in a lot of unrelated changes. I'll accept CI/py-support related changes once they are made visible.

@MateuszCzubak MateuszCzubak force-pushed the support-python-3.7-and-3.8-in-travis branch 4 times, most recently from 7500b11 to 2fd34f2 Compare June 1, 2020 07:32
tests/test_async_with.py Outdated Show resolved Hide resolved
@@ -131,7 +131,9 @@ async def test_create_pool_deprecations(mysql_params, loop):
warnings.simplefilter("always")
Copy link
Member

Choose a reason for hiding this comment

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

Looking at this test closer, we could probably just suppress all the warnings except for the DeprecationWarning instead of trying to guess on what position it'll be under the next Python version.
Ref: https://docs.python.org/3/library/warnings.html#overriding-the-default-filter.

@MateuszCzubak WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@webknjaz I think that makes a lot of sense but it will look weird to limit to DeprecationWarning just in this one place and not in the others. Maybe it would be better to switch all related tests like this in a "refactoring commit", before the actual p3.7/p3.8 compatibility commit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm actually the are only 2 invokations of warnings.simplefilter("always") - I think it should be enough to change them both within the same commit - WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

Well, if you want to switch all, this needs to go into a separate PR. Let me merge this one and then we can do a follow-up.

@MateuszCzubak MateuszCzubak force-pushed the support-python-3.7-and-3.8-in-travis branch from 2fd34f2 to 165ef15 Compare June 1, 2020 09:01
@webknjaz webknjaz self-requested a review June 1, 2020 09:11
tests/conftest.py Outdated Show resolved Hide resolved
Some changes in tests were needed to make them pass:
- `issubclass(w[0].category, DeprecationWarning)` - previous version
breaks on python 3.7 executed with PYTHONASYNCIODEBUG=1
- `disable_gc` fixture - I can only suspect that in p3.7 and p3.8
the connection object was automatically garbage collected before the
`gc.collect()` was invoked.
- curosor `async for` usage was incorrect
@MateuszCzubak MateuszCzubak force-pushed the support-python-3.7-and-3.8-in-travis branch from 165ef15 to e4cba8f Compare June 1, 2020 09:32
@webknjaz webknjaz merged commit d842ec3 into aio-libs:master Jun 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants