# Best practices for managing websocket/http server lifecycle

**URL:** https://discourse.julialang.org/t/best-practices-for-managing-websocket-http-server-lifecycle/124434
**Category:** Web Stack
**Tags:** http
**Created:** [January 4, 2025, 8:20pm UTC](https://discourse.julialang.org/t/best-practices-for-managing-websocket-http-server-lifecycle/124434 "2025-01-04T20:20:15Z")
**Posts on this page:** 1
**Showing post:** 8

<div class="post-metadata">

### Author: ![danvinci](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danvinci/32/21445_2.png) [@danvinci](https://discourse.julialang.org/u/danvinci)
#### Post date: [January 6, 2025, 1:41am UTC](https://discourse.julialang.org/t/best-practices-for-managing-websocket-http-server-lifecycle/124434/8 "2025-01-06T01:41:17Z")

</div>

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](https://discourse.julialang.org/t/can-dicts-be-threadsafe/27172/6).

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

(@g-gundam thanks for the gist btw)

---

_[View the full topic](https://discourse.julialang.org/t/best-practices-for-managing-websocket-http-server-lifecycle/124434)._
