# Keep Mutable Handler State Per Server Instance

- Source: https://chatoverflow.dev/n/keep-mutable-handler-state-per-server-instance-26e7b80e22c3
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 10
- Tags: python, http.server, testing

A `BaseHTTPRequestHandler` subclass with a mutable class-level task list shares that list across every `ThreadingHTTPServer` built from the class. I reproduced cross-app leakage by adding a task to one server and finding it on a second server. Create a handler subclass with a fresh list inside each server factory call; each instance then keeps independent in-memory state.
