durusmail: quixote-users: Dulcinea: Using same request for retry?
Dulcinea: Using same request for retry?
2004-10-11
Dulcinea: Using same request for retry?
ThomasGüttler
2004-10-11
Hi,

I use the try_publish method from dulcinea in my publisher.
This method does reuses the request if a conflict error happens.
I had a bug where a request contains money-values which
get changed from string to int in one method, and then saved
in a different method. Up to now I use request.form for the
changed values, too. But if a conflict error occurs, this does
not work.

How do you handle this?

1: Don't change request.form
2: Recreate request.form on a conflict error?

Here is the code of dulcinea:

    def try_publish (self, request, path):
        """Try to process a single request.  Use the base class method to the
        do actual the work.  If a conflict error occurs retry a number of
        times.
        """
        for i in range(self.CONFLICT_RETRIES + 1):
            try:
                return SessionPublisher.try_publish(self, request, path)
            except ConflictError, exc:
                self.debug("ConflictError (%s): retrying request" % exc)
                local.get_connection().abort()
                request.response = HTTPResponse() # reset response object
                time.sleep(random.random() * (i+1))
        else:
            raise RuntimeError("too many conflict errors")

Thomas

--
Thomas Güttler, TBZ-PARIV GmbH, Bernsdorfer Str. 210-212, 09126 Chemnitz
Tel.: 0371/5221217 Fax:  0371/5221216


reply