Re: [Python-Dev] Twisted Isn't Specific (was Re: Trial balloon: microthreads library in stdlib)

2007-02-14 Thread Dave Cole
Phillip J. Eby wrote:
> At 04:25 PM 2/15/2007 +1300, Greg Ewing wrote:
>> Phillip J. Eby wrote:
>>> peak.events, for example, lets you have multiple event loops running in 
>>> the same or different threads.
>> Different threads is okay if you're willing to use threads,
>> but you might not. The reason you're using an event loop
>> may well be precisely so that you *don't* have to use
>> threads.
>>
>> And... how do you run multiple event loops simultaneously
>> in the *same* thread?
> 
> When one is nested inside the other.  This isn't a common need, but it's 
> occasionally useful if you need to switch back and forth between blocking 
> and non-blocking code.  For example, suppose that you have some code that 
> wants to offer a synchronous interface to an asynchronous library...  and 
> the synchronous code is being called from a FastCGI "accept" event 
> loop.  The inner code can't use the outer event loop, because the outer 
> loop isn't going to proceed until the inner code is finished.

I actually have some code that works a little bit like this.

I have a SelectLoop class that the application knows about and 
explicitly attaches transport objects to, and queues events on the loop. 
  I have two ways to perform some actions in a "blocking" way.

1) I can create a new SelectLoop and move some transports temporarily 
from the main loop to the temporary loop to ignore all other events for 
a while.

2) I can re-enter the SelectLoop run() method and keep reacting to all 
events.  Once the right event occurs - I exit from the nested run() and 
continue on.  This does require a lot more mental effort though.

Note that my code is nowhere near as ambitious as Twisted, but I watned 
to have the above flexibility.  The code really only has to work on AIX 
and Linux, and in a limited way, Windows.

- Dave
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] PEP 8 updates/clarifications

2005-12-14 Thread Dave Cole
Barry Warsaw wrote:
> I've pushed out a revised PEP 8
> 
> http://www.python.org/peps/pep-0008.html
> 
> Please review and comment.  Thanks everyone for providing an excellent
> discussion.  Hopefully I have captured our current collective
> recommendations.  I've also tried to simplify the text, while making it
> (somewhat) more prescriptive.

The only thing I strongly disagree with is the promotion of javaNaming
to equal footing with python_naming.  We can look forward to future
programs that look like this:

class Something:

  def __init__(self, i_care):
 self.mem_a = pkga.uses_python_naming()
 self.mem_b = pkgb.usesJavaNaming()
 if i_care:
self.this_looks(self.mem_b.reallyCrap())

It gets worse if you subclass from modules using different conventions
in your own code.  Ugly code.

- Dave

-- 
http://www.object-craft.com.au
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com