Static methods and thread safety

In python with all this idea, “Everything is an object”, where does thread safety exist?

I am developing a django site with wsgi. It will also work on Linux, and as I know, they use efficient process control, so we could not think much about thread safety. I have no doubt about how the module loads, and are the functions static there or not? Every information would be helpful.

+3
source share
2 answers

Functions in a module are equivalent to static methods in a class. A thread safety problem arises when several threads can modify shared data, or even one thread can change such data while others read it; it is best avoided if the data belongs to the ONE module (access via Queue.Queue from others), but when this is not possible, you need to resort to locking and other, more complicated synchronization primitives.

, , , , , ( , , - pont, - - , "" ).

multiprocessing Python, threading, " " - , ... , , , mmap ; -).

+8

. python, Python.

, Django 1.0.3, , , ...

, (, apache 'prefork' MPM ).

0

Source: https://habr.com/ru/post/1712410/


All Articles