So this is related to my original post... Malcolm was right, the problem was related to the connection being closed prematurely.
I am having the same problem as these guys: http://stackoverflow.com/questions/393637/django-fastcgi-randomly-raising-operationalerror That is what happens on our live server. We randomly get this error about 10-15 times a day. It seems somewhat related to http://code.djangoproject.com/ticket/9437 but we have maxrequest set to 5. On my local machine the error happens much more. The first time I hit the site the page (doesn't matter which page) displays fine. Then I hit refresh and get: Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/site-packages/flup/server/fcgi_base.py", line 558, in run protocolStatus, appStatus = self.server.handler(self) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/site-packages/flup/server/fcgi_base.py", line 1116, in handler result = self.application(environ, start_response) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/site-packages/django/core/handlers/wsgi.py", line 246, in __call__ signals.request_finished.send(sender=self.__class__) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/site-packages/django/dispatch/dispatcher.py", line 148, in send response = receiver(signal=self, sender=sender, **named) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/site-packages/django/db/__init__.py", line 46, in close_connection connection.close() File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/site-packages/django/db/backends/__init__.py", line 51, in close self.connection.close() InterfaceError: connection already closed And when I hit refresh again I get: Traceback: File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ site-packages/django/core/handlers/base.py" in get_response 86. response = callback(request, *callback_args, **callback_kwargs) File "/Users/sheatsp2/www/backyardpost/trunk/backyardpost/realestate/ views.py" in home 114. if not request.session.has_key('florida_home'): File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ site-packages/django/contrib/sessions/backends/base.py" in has_key 109. return self._session.has_key(key) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ site-packages/django/contrib/sessions/backends/base.py" in _get_session 172. self._session_cache = self.load() File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ site-packages/django/contrib/sessions/backends/db.py" in load 16. expire_date__gt=datetime.datetime.now() File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ site-packages/django/db/models/manager.py" in get 93. return self.get_query_set().get(*args, **kwargs) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ site-packages/django/db/models/query.py" in get 304. num = len(clone) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ site-packages/django/db/models/query.py" in __len__ 160. self._result_cache = list(self.iterator()) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ site-packages/django/db/models/query.py" in iterator 275. for row in self.query.results_iter(): File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ site-packages/django/db/models/sql/query.py" in results_iter 206. for rows in self.execute_sql(MULTI): File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ site-packages/django/db/models/sql/query.py" in execute_sql 1734. cursor.execute(sql, params) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ site-packages/django/db/backends/util.py" in execute 19. return self.cursor.execute(sql, params) Exception Type: OperationalError at / Exception Value: server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. Then as I keep hitting refresh it will randomly display one of the above 3 options (correctly, InterfaceError, or OperationalError). If I comment out the call to connection.close() in db.__init__.py like so: # Register an event that closes the database connection # when a Django request is finished. def close_connection(**kwargs): # connection.close() pass signals.request_finished.connect(close_connection) my local site works fine -- I don't get any of the errors. I have not tried this on our live site yet since I have no idea of the implications of a change like that. A related question: When I use django.db.connection.cursor() am I supposed to call close() myself when I am done? Right now I don't call close anywhere. Any pointers, suggestions, or solutions would be tremendously appreciated. The site is going live on a couple weeks and if I can't get to the bottom of this I will probably switch to using Apache and mod_wsgi. Thanks, Peter On Mar 23, 8:57 pm, Malcolm Tredinnick <[email protected]> wrote: > On Mon, 2009-03-23 at 12:11 -0700, PeterSheatswrote: > > [...] > > > The error I was getting before was just a "connection already closed > > error" until I changed the following in wsgi.py line 235-248: > > Well, that's really the more important issue, then. Why is the > connection already closed when Django expects it to already be opened. > You need to investigate that problem a bit more, I think. It's related > to the error you get when you change things (since the attempt to close > off the savepoint will be causing a new connection to be opened, which > will have a different transaction status, etc -- it's all a consequence > of the first problem). > > Regards, > Malcolm --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---

