|
| 1 | +4.2.0 Release Notes |
| 2 | +=================== |
| 3 | + |
| 4 | +Channels 4.2 introduces a couple of major but backwards-compatible |
| 5 | +changes, including most notably enhanced async suppport and fixing |
| 6 | +a long-standing bug where tests would try and close db connections |
| 7 | +and erroneously fail. |
| 8 | + |
| 9 | +Additionally, support has been added for Django 5.1. |
| 10 | + |
| 11 | +Enhanced Async Support |
| 12 | +---------------------- |
| 13 | + |
| 14 | +Support for asynchronous consumers has been greatly improved. |
| 15 | +The documentation has been updated to reflect the async ORM |
| 16 | +features added in Django 4.2. A new `channels.db.aclose_old_connections` |
| 17 | +function has been added to easily close old database connections |
| 18 | +in async consumers. |
| 19 | + |
| 20 | +Warning: Channels now automatically closes connections in async |
| 21 | +consumers before a new connection, after recieving message (but |
| 22 | +before dispatching to consumer code), and after disconnecting. |
| 23 | + |
| 24 | +This change has been made to more closely align with Django's |
| 25 | +request/response cycle, and to help users avoid attempting |
| 26 | +to use stale/broken connections. |
| 27 | + |
| 28 | +Notably, Channels does NOT close connections before or after |
| 29 | +a consumer **sends** data. This is to avoid database churn and |
| 30 | +more closely align with user expectations. Instead, users are |
| 31 | +expected to call `aclose_old_connections` occasionally during |
| 32 | +long-lived async connections. |
| 33 | + |
| 34 | +Additionally, channels will automatically use the new async |
| 35 | +interface for sessions if Django 5.1 or greater is installed. |
| 36 | +This new interface can be slightly faster in certain cases |
| 37 | +as it does not always need to context-switch into synchronous |
| 38 | +execution. This does require a backwards-incompatible change to |
| 39 | +`channels.sessions.InstanceSessionWrapper`: the `save_session` |
| 40 | +function is now `async`. If `InstanceSessionWrapper` was being |
| 41 | +subclassed in some way (note that this class is an implementation |
| 42 | +detail and not documented) and `save_session` was being called |
| 43 | +or overridden, it will need to be updated to be called with `await` |
| 44 | +or defined as `async`, respectively. |
| 45 | + |
| 46 | + |
| 47 | +Bugfixes & Small Changes |
| 48 | +------------------------ |
| 49 | + |
| 50 | +* Database connections are no longer closed inside tests, which |
| 51 | + prevents erroneous "Cannot operate on a closed database" errors |
| 52 | + when running tets. |
| 53 | + |
| 54 | + Thanks to Jon Janzen. |
| 55 | + |
| 56 | +* An old import override and an unused deprecation message were removed |
| 57 | + |
| 58 | + Thanks to @sevdog (Devid) and Jon Janzen. |
| 59 | + |
| 60 | +* WebsocketCommunicator now has informative `assert` error messages |
| 61 | + |
| 62 | + Thanks to Karel Hovorka. |
0 commit comments