Update to Python 3.10 and async-rediscache v1.0.0#2229
Conversation
58c858f to
7d924d4
Compare
3180870 to
57da38e
Compare
HassanAbouelela
left a comment
There was a problem hiding this comment.
This is a well polished PR. I like the test changes, and I didn't find any issues while testing. Signing off on the docker changes on behalf of dev-ops.
17251de to
a6770ce
Compare
| global redis_session | ||
| redis_session = RedisSession(use_fakeredis=True) | ||
| redis_loop.run_until_complete(redis_session.connect()) | ||
| asyncio.run(redis_session.connect()) |
There was a problem hiding this comment.
This seems wrong because asyncio.run creates a new event loop. Presumably this will be separate from the event loop the rest of the tests use, unless unittest accounts for that somehow.
There was a problem hiding this comment.
There isn't a running loop when redis_loop was created, nor is there one during module setup, so the asyncio.get_event_loop() call was raising a deprecation error.
I think the alternative to this is to create the session within each test class as an asyncSetUp, rather than at the module level.
There was a problem hiding this comment.
I've pushed both 1b6b76f (#2229) and b5797ff (#2229) to show what this alternative could look like.
By importing the coro directly, the below warnings are raised (malloc enabled to see object allocation) I am not too sure why this happens either, as the coro is never called, but by namespacing the import like this the warnings go away.
This is fine with unnittest as the setUp function gets called before each test method. |
I had a look into it and it seems to be fundamentally because of this: https://nose.readthedocs.io/en/latest/doc_tests/test_doctest_fixtures/doctest_fixtures.html?highlight=setup#module-level-fixtures pytest sees a function called The check for Anyway, maybe we should add a comment saying something like "setup should not be imported directly or pytest will try and run it" just to be clear?
Ooh yeah of course. |
You aren't quite looking at the right line: This doesn't use nose, and it's what's called for us. Refer to TB: File "site-packages\_pytest\fixtures.py", line 1111
result = call_fixture_func(fixturefunc, request, kwargs)
File "site-packages\_pytest\fixtures.py", line 883
fixture_result = next(generator)
File "site-packages\_pytest\python.py", line 563
_call_with_optional_argument(setup_module, request.module)
File "site-packages\_pytest\python.py", line 776
func(arg) |
wookie184
left a comment
There was a problem hiding this comment.
One thing, other than that all seems good, nice work 💯
The bot service was still configured to depend on the snekbox service, even though this service is now optional, in favour of the snekbox-311 service.
get_event_loop is deprecated as of 3.10 if there is no running loop.
These warnings were caused by the setup coro from error_handler.py being imported directly, causing a warning about an un-awaited coro whenever the Cog was accessed from the same file.
This commit resolves all the breaking changes from the aioredis -> redis-py migration.
This has been abstracted away, the correct way to do this now is to directly access the client.
If a float is given, Redis will assume the expiry is in milliseconds and must be multiplied by 1000. This is undesirable, as we are already passing the expiry in seconds.
This was a new lint rule added in the latest bugbear.
pep-naming now supports these functions being in camel case.
This helper ensures that a fresh RedisSession is given to each test case that inherits from it.
The new versions introduce conversions which causes the doc command embed to be formatted improperly
eca5597 to
dc68bb2
Compare
Description
This PR does the following things related to the PR description:
0797e70(#2229)160d906(#2229)7331a17(#2229)c3a7e81(#2229)ac589c6(#2229)a165c06(#2229)DocRedisCache.setas this has multiple async calls to Redis that could have concurrency issues8436e36(#2229)0aa816b(#2229)iscanrenamed toscan_iter6843a8a(#2229)This PR also has the following kaizen commits:
ddbc1cf(#2229)get_event_loop()when there is no running loop482260a(#2229)ade1302(#2229)6217513(#2229)83a400e(#2229)cb55a62(#2229)