#22556: close_if_unusuable_or_obsolete should handle InterfaceError
----------------------------------------------+--------------------
     Reporter:  pennersr                      |      Owner:  nobody
         Type:  Uncategorized                 |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  1.6
     Severity:  Normal                        |   Keywords:
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+--------------------
 With Django 1.6.2 I ran into the following stack trace:

 {{{
 ...
     close_old_connections()
   File "/somewhere/virtualenv/local/lib/python2.7/site-
 packages/django/db/__init__.py", line 94, in close_old_connections
     conn.close_if_unusable_or_obsolete()
   File "/somewhere/virtualenv/local/lib/python2.7/site-
 packages/django/db/backends/__init__.py", line 462, in
 close_if_unusable_or_obsolete
     if self.is_usable():
   File "/somewhere/virtualenv/local/lib/python2.7/site-
 packages/django/db/backends/postgresql_psycopg2/base.py", line 192, in
 is_usable
     self.connection.cursor().execute("SELECT 1")
 InterfaceError: connection already closed
 <... at 0xac6ec0c> failed with InterfaceError
 }}}

 I see that `close_if_unusuable_or_obsolete` gracefully handles
 `DatabaseError` exceptions. Shouldn't `InterfaceError` be caught as well?

 FWIW -- I am invoking `close_old_connections` myself because I am making
 heavy use of greenlets. I would like to call a Django method to close
 connections if needed, without having to worry about exceptions like
 these.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/22556>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/051.07877a879d8c4bb3702cf9b1e2e448e0%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to