[storm] Pooling ?
andy at belator.com
Tue Nov 20 16:56:13 GMT 2007
1) The guys from storm I think are going to answer this question as
they were the ones who advised me on it. Basically it just makes
things easier for me. If you look at the code I look for any errors
and do an auto rollback if needed. Otherwise it attempts to do a
commit to commit any changes. With this tool you can also turn this
on / off with the tools.storm.on = False in your config.
2) Disconnects from the database are now fixed in the trunk version of
storm. Storm will now try and auto reconnect to the db on the threads
2.1) Fumanchu_ when he means request, he thinks it is best to grab a
connection from a pool during the request and then return it to the
pool after it's finished as opposed to 1 connection per thread. I am
sure a more experienced Python programmer could write a pooling
mechanism for CherryPy / Storm, at this point I was not able to
although Neimeiyer gave me some code to look into on how it can be done.
On a side note I am talking to Fumanchu_ to have him review my tool,
just to see if there are any more features I can add to make it rock
solid with CherryPy.
On Nov 20, 2007, at 11:35 AM, Håvard Gulldahl wrote:
> On Sun, 2007-11-18 at 11:19 -0500, Andrew Holman wrote:
>> That is actually my code that I was working with the guys in #storm
> Well, that was quite a coincidence. :)
>> and #cherrypy on. I wound up getting this working. I also added a
>> wiki entry to the tools section on the cherrypy.org website. The
> Nice. (The url is http://tools.cherrypy.org/wiki/Storm for anyone
> I have some questions that I hope you don't mind me asking.
> In the example you're commiting after a store.find() -- is that just
> the sake of argument?
> More generally, why are you store.commit()-ing on every request? Since
> the store is local to the thread, wouldn't getting stuff from the
> cache (that commit() invalidates) be more convenient?
> How do you handle disconnects?
> Previously, one of the cherrypy devs (fumanchu) stated that in
> certain circumstances, there is no clean way to detect and disconnect
> when a thread ends, and made the case for per-request database
> connections. Has this changed?
> : http://osdir.com/ml/python.cherrypy/2006-10/msg00015.html
> Other than that - to these inexperienced eyes, it looks like a good,
> clean way to combine cherrypy and storm.
>> has been expanded and so far is working great. A big thanks go out to
>> Niemeyer, Radix, fumanchu_ (cherrypy), dowski and the gang in
>> This code is for the beta version of Cherrypy 3.1 so things would be
>> different in 3.0.
> I'd like to repeat those thanks to everyone involved. This is great
>> - Andy
>> On Nov 17, 2007, at 9:44 PM, Håvard Gulldahl wrote:
>>> Hello, Andy, list,
>>> On 11/7/07, Andrew Holman <andy at belator.com> wrote:
>>>> I am working with CherryPy and am trying to figure out the best way
>>>> to incorporate Storm into it. Does Storm have any connection
>>> I'm currently in the same situation, and I freely admit that I find
>>> thread programming conceptually nauseating. However, I just came
>>> this little pastie:
>>> http://pastie.caboo.se/pastes/117963 (author unknown)
>>> and it seems to do the right thing: attach a new store to each newly
>>> created thread.
>>> def connect_db(thread_index):
>>> database =
>>> cherrypy.thread_data.store = Store(database)
>>> cherrypy.engine.subscribe('start_thread', connect_db)
>>>> If not then what is the best way to handle ensuring the connections
>>>> are still alive with each thread? I would assume we would have to
>>>> write something that would do a check/auto-connect if the threads
>>>> connection was no longer alive. How should that be handled?
>>> Now this doesn't handle disconnects, but it may serve as a useful
>>> starting point. What do you think?
>>> Håvard Gulldahl <havard at gulldahl.no>
>> Andrew Holman
>> E-Mail: andy at belator.com
>> Skype: belator-andy
E-Mail: andy at belator.com
More information about the storm