Best practices for managing websocket/http server lifecycle

So, I kept investigating the issue, and this is my understanding so far.
Some context first:

  • the code above is part of a personal project
  • the call to msg_handler function is part of a chain of ~dozen functions, with each using setters/getters on a global dictionary
  • I’m using re-entrant locks with the try/catch/finally pattern

What happened:

  • one of the msg_handlers task didn’t terminate correctly, and kept holding the lock
  • this blocked any following msg_handler tasks, so the whole service could only receive but never respond

Now I’m trying to nail down in which function downstream this happens and how.

As for Visor: thanks for sharing, I didn’t know about it!

(@g-gundam thanks for the gist btw)

2 Likes