Inside of an XMLRPCController I have a function that inserts items
into a database, and returns 'OK' to the client if everything works.
Everything runs quickly and correctly, the rows are inserted into the
DB, but pylons hangs for about a minute when generating the response.
The client hangs there waiting for a response while pylons does
*something*.

If I comment out the SQLAlchemy orm code, and don't insert the rows
into the database, the 'ok' response is generated instantly and
returned to the client just like all my other XMLRPC functions.

Why would using SQLAlchemy cause pylons to hang when returning a
response?  The rows are inserted into the database just fine.

My Code
==================================================
try:
        orm.flush()
        orm.commit()
except Exception, e :
        orm.rollback()  # Rollback transaction
        # Release all connections and expunge objects
        # Don't allow any other code to use session, full of bad data
        orm.remove()
        return Fault(30, 'Could not insert rows.')
return 'OK'

Pylons DEBUG output while the client is left hanging there
==============================================================
[pylons.controllers.core]Calling Response object to return WSGI data
[pylons.controllers.core] Merging pylons.response headers into
start_response call, status: 200 OK

I have found the code that emits this pylons log info.
I am using pylons .9.6
=============================================================================
 def repl_start_response(status, headers, exc_info=None):
            response = pylons.response._current_obj()
            start_response_called.append(None)

            # Copy the headers from the global response
            # XXX: TODO: This should really be done with a more
efficient
            #            header merging function at some point.
            if log_debug:
                log.debug("Merging pylons.response headers into "
                          "start_response call, status: %s", status)
            response.headers.update(HeaderDict.fromlist(headers))
            headers = response.headers.headeritems()
            for c in pylons.response.cookies.values():
                headers.append(('Set-Cookie', c.output(header='')))
            return start_response(status, headers, exc_info)
        self.start_response = repl_start_response

I see that in .9.7 this code has been changed to
=====================================================================
def repl_start_response(status, headers, exc_info=None):
    response = self._py_object.response
    start_response_called.append(None)

    # Copy the headers from the global response
    if log_debug:
        log.debug("Merging pylons.response headers into "
                  "start_response call, status: %s", status)
    for header in response.headerlist:
        if header[0] == 'Set-Cookie' or header[0].startswith('X-'):
            headers.append(header)
    return start_response(status, headers, exc_info)
self.start_response = repl_start_response


How can the code in .9.6 cause pylons to hang while returning a
response to the client ONLY when I use SQLalchemy to insert some rows?


Bryan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to