V
V
VkolV2020-12-23 20:41:21
Django
VkolV, 2020-12-23 20:41:21

How to make a thread safe tag?

I want to start with a simple increment in the template.
Wrote a tag, he added a unit to "himself", wrote the tag again, he added a unit to himself again.
BUT there is a doubt - a bunch of users went to the page and summed up ... :)
How to make it thread-safe?
PS (maybe I misunderstand something and my doubts are in vain - please clarify)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dr. Bacon, 2020-12-23
@bacon

The template, and the tag is about the output of information. No need to make a tag that changes its state for some reason.

A
Alexey Cheremisin, 2020-12-23
@leahch

Install redis and store your counters in it!

P
Pasechnik Kuzmich, 2020-12-23
@Hivemaster

In yourself - where is it? Django is single threaded. But the WSGI server often runs it in multiple processes, so there shouldn't be any shared state anywhere other than the database.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question