[Python-Dev] Active Objects in Python

Nick Coghlan ncoghlan at gmail.com
Wed Sep 28 11:00:43 CEST 2005

Greg Ewing wrote:
> Nick Coghlan wrote:
>>PEP 342's yield expressions can probably be used to help address that problem, 
>>   class SomeAO(ActiveObject):
>>     def processSomeMessage(self):
>>       msg = yield
>>       # Do something with the message
>>       next_msg = yield makeSomeBlockingCall(self)
>>       # Do something with the next message
> I don't see how that helps, since makeSomeBlockingCall()
> is evaluated (and therefore blocks) *before* the yield
> happens.

Chris got it right - I just named the function badly. The idea is that there 
would be an interaction with the Active Object's event loop to get the actual 
result back once it was available from the thread that actually made the 
blocking call. In the meantime, *this* object could continue to handle other 

What the approach allows is to have a single physical thread with a number of 
coroutiney-type event handlers running inside it.


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-Dev mailing list