Error in action handling

Bug #1050852 reported by Robert Collins
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-timeline-django
Fix Released
Critical
Robert Collins

Bug Description

I tried timeline-django 0.0.1 with django 1.3.3, my branch to test this is up at lp:~lifeless/python-oops-tools/timeline

Doing that introduced an OOPS

  AssertionError: post action called without pre action.

      File "/home/robertc/source/launchpad/oops-tools/working/eggs/oops_wsgi-0.0.10-py2.6.egg/oops_wsgi/middleware.py", line 208, in oops_middleware
    app(environ, oops_start_response))
  File "/home/robertc/source/launchpad/oops-tools/working/eggs/timeline-0.0.3-py2.6.egg/timeline/wsgi.py", line 29, in wrapper
    return app(environ, start_response)
  File "/home/robertc/source/launchpad/oops-tools/working/eggs/Django-1.3.3-py2.6.egg/django/core/handlers/wsgi.py", line 274, in __call__
    signals.request_finished.send(sender=self.__class__)
  File "/home/robertc/source/launchpad/oops-tools/working/eggs/Django-1.3.3-py2.6.egg/django/dispatch/dispatcher.py", line 172, in send
    response = receiver(signal=self, sender=sender, **named)
  File "/home/robertc/source/launchpad/oops-tools/working/eggs/timeline_django-0.0.1-py2.6.egg/timeline_django/hooks.py", line 100, in request_finished
    self._handle_post(self.REQUEST_CATEGORY, sender, **kwargs)
  File "/home/robertc/source/launchpad/oops-tools/working/eggs/timeline_django-0.0.1-py2.6.egg/timeline_django/hooks.py", line 70, in _handle_post
    raise AssertionError("post action called without pre action.")

Related branches

Revision history for this message
Robert Collins (lifeless) wrote :

To reproduce, grab lp:python-oops-tools
make
bin/buildout
bin/django syncdb
edit bin/oopstools.wsgi and make the end be
application = make_app(application, config, oops_on_status=['500'],
    soft_start_timeout=500)
from wsgiref.simple_server import make_server
make_server('127.0.0.1', 8080, application).serve_forever()

Apply this patch:
=== modified file 'src/oopstools/oops/models.py'
--- src/oopstools/oops/models.py 2012-07-27 04:27:53 +0000
+++ src/oopstools/oops/models.py 2012-09-14 10:45:28 +0000
@@ -554,6 +554,7 @@

     @readproperty
     def parsed_oops(self):
+ import time;time.sleep(1)
         self.parsed_oops = _get_oops(self.pathname)
         return self.parsed_oops

And finally run
bin/py bin.oopstools.wsgi
and hit any existing oops. If you don't have one, delete the 404.html template and hit a missing page. That will generate an oops (and you'll need amp2disk running to nab it and load it), then you can visit the oops, the sleep will kick in and the race or whatever it is will show up.

Revision history for this message
Robert Collins (lifeless) wrote :

So looking the code, this will die if a post signal is sent without a pre signal, but the exception doesn't tell us enough about what went wrong.

I think there are two things we can/should do here:
a) make the exception better so we can determine what sort of cases trigger this
b) not raise at all: generate a new distinct OOPS to record the problem (cloning the current OOPS' state and timeline).

I'll attach a branch to do A for now.

Revision history for this message
Robert Collins (lifeless) wrote :

Ok, we captured this on oops.c.c:

https://oops.canonical.com/?oopsid=OOPS-8d2c1063a562769b55e6d3df2e9f012d

  AssertionError: post action called without pre action. action_name='request-oops_wsgi.django.OOPSWSGIHandler'

      File "/srv/oops.canonical.com/python-oops-tools/eggs/oops_wsgi-0.0.10-py2.7.egg/oops_wsgi/middleware.py", line 208, in oops_middleware
    app(environ, oops_start_response))
  File "/srv/oops.canonical.com/python-oops-tools/eggs/timeline-0.0.3-py2.7.egg/timeline/wsgi.py", line 29, in wrapper
    return app(environ, start_response)
  File "/srv/oops.canonical.com/python-oops-tools/eggs/Django-1.3.3-py2.7.egg/django/core/handlers/wsgi.py", line 274, in __call__
    signals.request_finished.send(sender=self.__class__)
  File "/srv/oops.canonical.com/python-oops-tools/eggs/Django-1.3.3-py2.7.egg/django/dispatch/dispatcher.py", line 172, in send
    response = receiver(signal=self, sender=sender, **named)
  File "/srv/oops.canonical.com/python-oops-tools/eggs/timeline_django-0.0.1-py2.7.egg/timeline_django/hooks.py", line 102, in request_finished
    self._handle_post(self.REQUEST_CATEGORY, sender, **kwargs)
  File "/srv/oops.canonical.com/python-oops-tools/eggs/timeline_django-0.0.1-py2.7.egg/timeline_django/hooks.py", line 72, in _handle_post
    (action_name,))

Revision history for this message
Robert Collins (lifeless) wrote :

Ok, I have a plausible explanation.
_handle_pre checks for
if timeline is None:
   return

_handle_post does not, so it will just hope there is an action, but _handle_pre will only add one when there is a timeline.

James Westby (james-w)
Changed in python-timeline-django:
status: New → Fix Released
importance: Undecided → Critical
assignee: nobody → Robert Collins (lifeless)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.