[Stackless] Stackless with ZODB
johanc at easypublisher.com
Mon Sep 17 23:41:09 CEST 2007
Ok did some more testing...
I've god the latest standalond version of ZODB and I'm using the
standard config for a FileStorage and the following function:
def test_task(ch, data="No data"):
print i, "test_task", data
data = ch.receive()
root is the root ZODB mapping object.
root['talk'] = stackless.channel()
root['task']=stackless.tasklet(test_task)(root['talk'], "first data")
Now running root['talk'].send("hello") works fine the counter counts up.
Because tasklets and channels isn't Persistent-aware they need to be
rewritten, so after calling send on the channel for a couple of whiles
I do this:
root['task'] = root['task']
root['talk'] = root['talk']
closing down the database and restarting the Python and reopening the
root['task'].insert() # to make add it to the current stackless scheduler.
Returns the next i from the calls before the commit above.
Just like you would expect :-D
So for now I'd say stackless plays nice with ZODB, at least
for a simple scenarios like this.
I'm guessing that putting all tasklets in a list in the ZODB and
initiate them at start up of the system would be a nice way to
run a Stackless persistent simulation (or something equal, like a game).
There might be problems with channels not being loaded, and if
something is gets thrown out of RAM I don't know what will happen.
Well, at least this wouldn't work with ORMs ;-D
I'll come back with more experiences when I have more ;-D
Colliberty Easy Publisher
More information about the Stackless