kytos-ng / kytos

Kytos SDN Platform. Kytos is designed to be easy to install, use, develop and share Network Apps (NApps).
https://kytos-ng.github.io/
MIT License
2 stars 7 forks source link

enhancement: try to find a more graceful way to stop QueueListener when stopping `kytosd` #418

Open viniarck opened 9 months ago

viniarck commented 9 months ago

To quote from cpython std lib QueueListener.stop() method:

Stop the listener.

    This asks the thread to terminate, and then waits for it to do so.
    Note that if you don't call this before your application exits, there
    may be some records still left on the queue, which won't be processed.

So, when QueueLogger is used, ideally, we want it also fully stopped in the main thread https://github.com/kytos-ng/kytos/blob/master/kytos/core/kytosd.py#L153-L159 that's also managing the event loop.

I've seen cases where we might lose a message in the log depending how early an exception happens https://github.com/kytos-ng/kytos/pull/414#discussion_r1337589796, for now we've using a print statement to be safe too to at least have it in the stdout.