[Stackless] Stackless nonblocking file IO module... (monkeypatch)

Carlos Eduardo de Paula carlosedp at gmail.com
Fri Apr 27 20:28:52 CEST 2007


There it is... the final one.. I think i pretty much covered the
functions and error that might appear... hope it helps out.

I have fixed the missing tasklets and the communications in case of
success and errors. I also added the usage example and commentaries in
it.

The code is in:  http://dpaste.com/hold/9178/

Its checked in SVN under:
http://stacklessexamples.googlecode.com/svn/trunk/examples/fileIO/stacklessfile.py

Any comments please, mail me...

Regards,

Carlos


On 4/26/07, Carlos Eduardo de Paula <carlosedp at gmail.com> wrote:
> I think I fixed it having a tasklet to manage the callback... here
> follows the last version. As soon as I finish some tests and put the
> other file methods I will commit it to the SVN.
>
> http://dpaste.com/hold/9124/
>
> Carlos
>
> On 4/26/07, Carlos Eduardo de Paula <carlosedp at gmail.com> wrote:
> > One problem I found out is that in my example, I fire multiple
> > tasklets to start a file copy. They all call the read/write functions
> > which are fired to the threadpool and gets blocked on a channel. When
> > the thread finish the operation, it does a ch.send(data) back to the
> > tasklet. The problem is that some tasklets doesnt finishes the
> > operation because the current existing tasklets are all blocked on a
> > channel, with this the scheduler finishes.
> >
> > If I create a tasklet to do nothing but run, this problem dont happen.
> > To check this put a print "Start %s" % stackless.getcurrent() and a
> > print "Finish %s" % stackless.getcurrent()" at the start and the end
> > of the copyfile function. All tasklets start but not all of them
> > "finishes"...
> >
> > Any idea on how to deal with this?
> >
> > Carlos
> >
> > On 4/25/07, Carlos Eduardo de Paula <carlosedp at gmail.com> wrote:
> > > For now this only implements read() and write() .. do you think this
> > > is a problem? I found this way better because the other functions are
> > > not noticeably blocking like read and write...
> > >
> > > I´m gonna take another look at it and then gonna check in the SVN.
> > >
> > > If someone found any issue on this, please let me know...
> > >
> > > Carlos
> > >
> > > On 4/25/07, Richard Tew <richard.m.tew at gmail.com> wrote:
> > > > On 4/24/07, Carlos Eduardo de Paula <carlosedp at gmail.com> wrote:
> > > > > Based on an idea used in some async frameworks like tiwsted, I created
> > > > > a concept for having nonblocking file IO access for tasklets.
> > > > >
> > > > > The idea is based on creating a threadpool and handling the IO
> > > > > requests to it, it has been based on a recipe from ASPN cookbook.
> > > > >
> > > > > Here follows the module and an example with the monkeypatching. If
> > > > > anyone can check it and point out the flaws on this approach I would
> > > > > be glad since this is my first shot on this.
> > > >
> > > > Looks really good Carlos.  It is a nice accompanyment to the
> > > > socket module.
> > > >
> > > > You should definitely check it into the examples SVN :-)
> > > >
> > > > Cheers,
> > > > Richard.
> > > >
> > >
> > >
> > > --
> > > -------------------------------------------------------------------
> > > Visit Stackless Examples Project
> > > http://code.google.com/p/stacklessexamples/
> > > Stackless Python - www.stackless.com
> > > -------------------------------------------------------------------
> > >
> >
> >
> > --
> > -------------------------------------------------------------------
> > Visit Stackless Examples Project
> > http://code.google.com/p/stacklessexamples/
> > Stackless Python - www.stackless.com
> > -------------------------------------------------------------------
> >
>
>
> --
> -------------------------------------------------------------------
> Visit Stackless Examples Project
> http://code.google.com/p/stacklessexamples/
> Stackless Python - www.stackless.com
> -------------------------------------------------------------------
>


-- 
-------------------------------------------------------------------
Visit Stackless Examples Project
http://code.google.com/p/stacklessexamples/
Stackless Python - www.stackless.com
-------------------------------------------------------------------

_______________________________________________
Stackless mailing list
Stackless at stackless.com
http://www.stackless.com/mailman/listinfo/stackless



More information about the Stackless mailing list