[Stackless] monkeypatching

Kristján Valur Jónsson kristjan at ccpgames.com
Sun Dec 1 14:35:47 CET 2013


In fact, it now exists in 
https://bitbucket.org/stackless-dev/stacklesslib

Yes, stacklessio is indeed internal legacy stuff and shouldn't be referred to in stacklesslib at all :)

stacklesslib provides, apart from monkeypatchin, the fundamental building blocks
for a stackless application, including an event manager and main loop.

as Richard suggests, take a look at magic.py in there, or test/teststdlibunittest.py or test/support.py

K
________________________________________
From: stackless-bounces at stackless.com [stackless-bounces at stackless.com] on behalf of Richard Tew [richard.m.tew at gmail.com]
Sent: Sunday, December 01, 2013 3:05 AM
To: The Stackless Python Mailing List
Subject: Re: [Stackless] monkeypatching

latest stacklesslib, i mean.

On 12/1/13, Richard Tew <richard.m.tew at gmail.com> wrote:
> Hi Lars,
>
> stacklessio is internal ccp stuff.
>
> main.py in stacklesslib is pretty much all you need to understand,
> beyond calling patch_all().  It is a scheduler, and makes your Open
> scheduler redundant.
>
> I suggest you get the latest stacklessio from:
>
> https://bitbucket.org/krisvale/stacklesslib
>
> And then you check out test / teststdlibunittests.py, which is a short
> example of monkey patching and running the stacklesslib scheduler.
>
> Cheers,
> Richard.
>
> On 12/1/13, lars van Gemerden <lars at rational-it.com> wrote:
>> sorry,
>>
>> patch_all seemed to simple, question was a bit rethoric ;-) tried it 2
>> mins
>> after pressing send just in case and indeed no cigar.
>>
>> I am trying to get this demo running and all kinds of last minute #### is
>> popping up.
>>
>> I tried reading the source but it doesn't click; i am not familiar with
>> using sockets etc. at all.
>>
>> e.g.
>>
>> - do i need 'stacklessio'?
>> - can i (essentially) just put a stackless.schedule() (or
>> OpenTasklets.schedule() in the code below) in the serve_forever loop?
>> - will this work at all with an adapted scheduler like this:
>>
>> class OpenTasklets(object):
>>
>>     _stop = False
>>
>>     @classmethod
>>     def run(cls, maxcount = None):
>>         cls.schedule_channel = stackless.channel()
>>         cls.schedule_channel.preference = 1
>>         counter = 0
>>         OpenTasklets._stop = False
>>         while stackless.getruncount() != 1:
>>             stackless.run()
>>             cls.reschedule(cls._stop or (maxcount and counter >
>> maxcount))
>>             counter += 1
>>
>>     @classmethod
>>     def schedule(cls):
>>         if cls.schedule_channel.receive():
>>             raise TaskletExit
>>
>>     @classmethod
>>     def reschedule(cls, stop = False):
>>         while cls.schedule_channel.balance < 0:
>>             cls.schedule_channel.send(stop)
>>
>> Any help is appreciated ..
>>
>> Lars
>>
>>
>>
>>
>> On Sat, Nov 30, 2013 at 8:53 PM, Richard Tew
>> <richard.m.tew at gmail.com>wrote:
>>
>>> Lars :-)
>>>
>>> Yes, there is no documentation for stacklesslib yet.  To use it, you
>>> really need to be willing to read the source code.
>>>
>>> You should already know whether calling patch_all would be enough.  It
>>> would have been something you could have tried immediately, rather
>>> than asking the list and waiting.
>>>
>>> Cheers,
>>> Richard.
>>>
>>> On 11/30/13, lars van Gemerden <lars at rational-it.com> wrote:
>>> > Hi all,
>>> >
>>> > I though i could avoid it to run my demo but it seems i need to let
>>> > the
>>> > webserver (simple server?, single thread, 'bottle' micro framework)
>>> > yield
>>> > to the scheduler i am using. I have downloaded stacklesslib 1.0.3, but
>>> > can't find any documentation to help with monkeypatching.
>>> >
>>> > - Do i just run patch_all at the start of the program?
>>> >
>>> > Any help is very welcome ..
>>> >
>>> > Cheers, Lars
>>> >
>>> > --
>>> > ====================================
>>> > Lars van Gemerden
>>> > lars at rational-it.com
>>> > +31 6 26 88 55 39
>>> > ====================================
>>> >
>>>
>>> _______________________________________________
>>> Stackless mailing list
>>> Stackless at stackless.com
>>> http://www.stackless.com/mailman/listinfo/stackless
>>>
>>
>>
>>
>> --
>> ====================================
>> Lars van Gemerden
>> lars at rational-it.com
>> +31 6 26 88 55 39
>> ====================================
>>
>

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



More information about the Stackless mailing list