#30448: close_if_unusable_or_obsolete should skip connections in atomic block
for
autocommit check
-------------------------------------+-------------------------------------
Reporter: Daniel | Owner: nobody
Hahler |
Type: Bug | Status: new
Component: Database | Version: 2.2
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Via https://github.com/django/channels/issues/1091#issuecomment-489488831
I have noticed that `close_if_unusable_or_obsolete` will close the DB
connection used in tests, which has entered an atomic block (via
`TestCase`).
channel's `DatabaseSyncToAsync` calls `close_if_unusable_or_obsolete`
here.
The following patch might make sense:
{{{
diff --git c/django/db/backends/base/base.py
i/django/db/backends/base/base.py
index 9fa03cc0ee..f9ca0f8464 100644
--- c/django/db/backends/base/base.py
+++ i/django/db/backends/base/base.py
@@ -497,7 +497,10 @@ def close_if_unusable_or_obsolete(self):
if self.connection is not None:
# If the application didn't restore the original autocommit
setting,
# don't take chances, drop the connection.
- if self.get_autocommit() != self.settings_dict['AUTOCOMMIT']:
+ if (
+ not self.in_atomic_block and
+ self.get_autocommit() !=
self.settings_dict["AUTOCOMMIT"]
+ ):
self.close()
return
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30448>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/050.8a20ee6462562e2d17948b14b2cdd941%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.