-
-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Data race in pongo2.FromFile()
method
#322
Comments
This might be related to #163 |
My temporary solution is to use var renderMu sync.Mutex
func RenderView() {
renderMu.Lock()
defer renderMu.Unlock()
tmpl, err := pongo2.FromFile("index.html")
// .... rest of the code
} |
Thanks for reporting, will have a look when time allows. |
If it's about the line set.firstTemplateCreated = true Then it's harmless, it's just unprotected access on a basically integer value, which on x86/x64 will "just" result in different CPUs seeing a different cached value until they are synced (which is usually unpredictable). The easiest fix would be to either convert See e.g. https://pkg.go.dev/sync/atomic#Bool |
I can confirm the issue is fixed by changing |
System:
Problem:
pongo2.FromFile()
method is having a data race when put underwrk
stress test. The commands I used for stress test is:Setup:
The setup is just a single view with data:
main.go
:index.html
:Result: Data Race
The text was updated successfully, but these errors were encountered: