[Fixed]-Django Class-Based View: Would a lock be reduntant in this example?

1👍

This instance cannot possibly be shared across threads, so there is no need for a lock here.

As the documentation you link to shows, each request is a thread-safe operation. As part of that, the ListView is instantiated for each request, and its get_context_data is called within that request. That means that the instantiation of MyClass is also only ever within a single thread.

Leave a comment