Continuously list for events
iamBiB opened this issue · comments
Bogdan commented
Hi,
I'm having an issue while waiting for events. I'm trying to continuously listen for incoming events and do something based on the event. It seems like i'm doing something wrong since the logs show up nothing.
Could you please help?
`class AmiConnect(Thread):
amiClient = None
lock = RLock()
def __init__(self):
Thread.__init__(self)
# self.setStatus(SERVICE_STARTED)
self.connectToAmi()
def connectToAmi(self):
try:
self.amiClient = AMIClient(address='5.2.196.226',port=5038)
self.amiClient.login(username='admin',secret='Rapid2017')
self.amiClient.add_event_listener(RegistryEventListener())
self.amiClient.add_event_listener(AllEventListener())
logging.info('Connected');
except Exception as e:
logging.info(e);
def setStatus(self, status):
self.lock.acquire()
self.status = status
self.lock.release()
def shutDown(self):
self.setStatus( SERVICE_STOPPING )
if name == 'main':
service = AmiConnect()
service.start()
try:
while (service is not None and service.isAlive() ):
service.join(1)
except KeyboardInterrupt as k:
logging.info("Keyboard interruption!")
service.shutDown()`
Éttore Leandro Tognoli commented
I'm not shure, but I think you don't need to use a tread there.
The AMIClient have a thread already.
Where you call the connectToAmi method?