Race when saving sessions
Nick Murtagh <[email protected]> Mon, 22 Oct 2007 16:55:11 +0100
| Newsgroups | gmane.comp.web.skunkweb |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I've noticed some strange behaviour in SkunkWeb that I finally tracked
down to a race when saving sessions. Here's what should happen:
Skunkweb Process 1: Load Session
Skunkweb Process 1: Save Session
Skunkweb Process 1: Redirect
Skunkweb Process 2: Load Session
Skunkweb Process 2: Save Session
Here's what happens some of the time:
Skunkweb Process 1: Load Session
Skunkweb Process 1: Redirect
Skunkweb Process 2: Load Session
Skunkweb Process 2: Save Session
Skunkweb Process 1: Save Session
Oops!
I resolved it by adding another KeyedHook to
Services/requestHandler/requestHandler.py
PreRequest=KeyedHook()
In _sendResponse I call this hook before send_it_all:
try:
PreRequest(Configuration.job, requestData, sessionDict)
except:
logException()
And finally in Services/sessionHander/__init__.py I replaced:
rr.PostRequest.addFunction(Session.saveSession, allweb)
with
rr.PreRequest.addFunction(Session.saveSession, allweb)
This fixes the problem for me, but there are a couple of issues:
- Is this the correct fix?
- I think the hook should probably be called something other than
PreRequest, perhaps PreSendResponse? Any suggestions?
--
Nick Murtagh <[email protected]>
go2web Ltd., Harbour House, Harbour Road, Howth, Dublin 13
http://www.go2.ie/ - Phone +353-(0)1-839-5432 - Fax +353-(0)1-839-5439
Registered in Ireland: No. 327376
Registered address: 53 Thormanby Lawns, Howth, Dublin 13
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/