[Twisted-Python] knowing which reactor is running

L. Daniel Burr ldanielburr at mac.com
Mon Oct 23 16:00:11 EDT 2006

Hi Manlio,

On Mon, 23 Oct 2006 14:27:03 -0500, Manlio Perillo  
<manlio_perillo at libero.it> wrote:

> L. Daniel Burr ha scritto:
>> On Mon, 23 Oct 2006 13:48:18 -0500, Manlio Perillo
>> <manlio_perillo at libero.it> wrote:
>>> Jean-Paul Calderone ha scritto:
>>>> On Sat, 21 Oct 2006 12:11:29 +0200, Manlio Perillo
>>>> <manlio_perillo at libero.it> wrote:
>>>>> In a test suite I need to know if the win32eventreactor is running.
>>>>> Any solution?
>>>> You generally shouldn't need this information.  Rather, you should  
>>>> rely
>>>> on the interfaces provided by the reactor you're using, and less
>>>> commonly
>>>> the modules which you are able to import.
>>> But the win32eventreactor does not implement a "special" interface  
>>> like,
>>> say, IWin32EventReactor.
>> [...]
>> Of course it doesn't, because interfaces aren't types.  Having an
>> interface named IWin32EventReactor makes no sense, because the
>> whole point of interfaces is to describe how something acts, not
>> what it is.  Types answer the question "what is this?"; interfaces
>> answer the question "what can I do with this?".
> Yes.
> IWin32EventReactor interface means that the reactor support the win32
> event system (addEvent, removeEvent).

An IWin32Event interface would suggest support for the win32 event system,
but adding "Reactor" to the end of that is wrong, in my opinion.

Naming conventions aside, yes, you have the right idea.  You'd check your
reactor instance to see if it supports the IWin32Event interface, rather
than checking the instance's class name.

> Regards  Manlio Perillo

Hope this helps,

L. Daniel Burr

More information about the Twisted-Python mailing list