If I read the django documentation, only the template tag documents indicate a potential thread safety hazard.
However, I'm curious what should I do / avoid writing thread-safe code in Django ...
One example: I have the following function to configure the loggers used in django.
_LOGGER_CONFIGURED = False def config_logger(): global _LOGGER_CONFIGURED if _LOGGER_CONFIGURED: return _LOGGER_CONFIGURED = True rootlogger = logging.getLogger('') stderr_handler = StreamHandler(sys.stderr) rootlogger.addHandler(stderr_handler)
and at the end of my root urlconf, I have the following function call:
config_logger()
The question arises:
Is this code unsafe?
What variables are shared between django threads?
django , , , , , , . django, , , cycle.
cycle
, : logging , , logging.getLogger , logging LOGGING_CONFIG settings.py. .
logging
logging.getLogger
LOGGING_CONFIG
settings.py
, , - . , PostgreSQL MySQL/INNOdb, concurrency shennanegans.
Source: https://habr.com/ru/post/1776307/More articles:clisp 2.49: asdf cannot find asd - common-lispGAE voice modeling - google-app-engineDo "!" and "zero" give the same result? - objective-ca simple mistake c makes a pointer out of the whole without casting - cAndroid: How to program EAP wifi configuration programmatically? - androidSpring AOP with anonymous inner classes - javaRMISecurityManager vs SecurityManager - javaAndroid programming error - androidпорядок и лимит с суммой ActiveRecord? - rubyfgetc (): Read and save a string of unknown length - cAll Articles