Closed bigfootjon closed 3 months ago
@carltongibson: I've added the missing test coverage (such as I could, see inline comment) and fixed the thing you noted.
I'm not sure this should be merged before https://github.com/django/channels/pull/2090 is resolved since sessions can use the Django ORM under the hood.
Yes, I too was thinking we need to settle that first 👍
Ref the breaking change here: I think if we're super clear in the release notes that may have to do.
Alright, we've got full test coverage now!
Once this PR is merged I'll add the backwards compat notices to: https://github.com/django/channels/pull/2111
Support was added in https://github.com/django/django/pull/17372 (slated for release in 5.1)
We can use this API if it exists, otherwise, we fallback to a
sync_to_async
bridge.This does break backwards compatibility, which I'm not terribly happy about but I'm not sure how best to fix it.
If users overrode
save_session
in a subclass they would expect that to still work, so I thought the best way to do this was to make it async in the base class and thenawait
it, so at least it will be obvious that it doesn't work (python will raise an exception aboutawait
ing a non-awaitable), but I'm open to other solutions.