On Apr 1, 2013, at 3:46 AM, chenli wrote:
> Thanks. Now I add some extra events and named it as Fail_server_invoke.py  
> like below:
> 
> from pox.core import core
> import pox.openflow.libopenflow_01 as of
> 
> from pox.lib.revent.revent import EventMixin
> log = core.getLogger()
> 
> class define_event(EventMixin):
>   _eventMixin_events = set([raise_fail])
> 
> 
> class Fail_server_invoke(object):
>   def __init__(self, intervals):
>     self.connections = set()# Attribute
>     self.interval = intervals
>     define_event.addListeners(self) #Add Listener
>     log.debug(" --------------------------------- ")
>     log.debug(" Fail_server_invoke_class wait for raise_fail event ")
>     log.debug(" --------------------------------- ")
> 
>   def _handle_raise_fail (self, event):
>     log.debug("Server failed")
> 
> 
> But I got some problems when I use another component to add following lines 
> in launch function.
> 
> core.registerNew( Fail_server_invoke, interval)
> define_event.raiseEvent(raise_fail("Generic"))

Events are published from objects, not classes.  define_event is a class -- you 
need an instance of it.  Is there just one, or will there be an instance of it 
per server or something?  In any case, you need an instance, and then you need 
to call addListeners and raiseEvent on the instance, not a class.

> And I also import the module Fail_server_invoke like below:
> from Fail_server_invoke import *
> 
> The error message is 'NameError: name 'raise_fail' is not defined', but I 
> already define 'raise_fail' in Fail_server_invoke.py

Hard to say what the problem is here without the code and/or a stack trace.


Hope that helps.

-- Murphy

Reply via email to