@@ -589,6 +589,33 @@ def TEMPLATES(self):
589
589
USE_I18N = True
590
590
USE_L10N = True
591
591
592
+ BUILD_TIME_LIMIT = 900 # seconds
593
+
594
+ @property
595
+ def BUILD_MEMORY_LIMIT (self ):
596
+ """
597
+ Set build memory limit dynamically, if in production, based on system memory.
598
+
599
+ We do this to avoid having separate build images. This assumes 1 build
600
+ process per server, which will be allowed to consume all available
601
+ memory.
602
+ """
603
+ # Our normal default
604
+ default_memory_limit = "7g"
605
+
606
+ # Only run on our servers
607
+ if self .RTD_IS_PRODUCTION :
608
+ total_memory , memory_limit = self ._get_build_memory_limit ()
609
+
610
+ memory_limit = memory_limit or default_memory_limit
611
+ log .info (
612
+ "Using dynamic build limits." ,
613
+ hostname = socket .gethostname (),
614
+ memory = memory_limit ,
615
+ )
616
+ return memory_limit
617
+
618
+
592
619
# Celery
593
620
CELERY_APP_NAME = "readthedocs"
594
621
CELERY_ALWAYS_EAGER = True
@@ -605,7 +632,7 @@ def TEMPLATES(self):
605
632
# https://github.com/readthedocs/readthedocs.org/issues/12317#issuecomment-3070950434
606
633
# https://docs.celeryq.dev/en/stable/getting-started/backends-and-brokers/redis.html#visibility-timeout
607
634
BROKER_TRANSPORT_OPTIONS = {
608
- 'visibility_timeout' : self . BUILD_TIME_LIMIT * 1.15 , # 15% more than the build time limit
635
+ 'visibility_timeout' : BUILD_TIME_LIMIT * 1.15 , # 15% more than the build time limit
609
636
}
610
637
611
638
CELERY_DEFAULT_QUEUE = "celery"
@@ -741,32 +768,6 @@ def _get_build_memory_limit(self):
741
768
# int and raise a ValueError
742
769
log .exception ("Failed to get memory size, using defaults Docker limits." )
743
770
744
- BUILD_TIME_LIMIT = 900 # seconds
745
-
746
- @property
747
- def BUILD_MEMORY_LIMIT (self ):
748
- """
749
- Set build memory limit dynamically, if in production, based on system memory.
750
-
751
- We do this to avoid having separate build images. This assumes 1 build
752
- process per server, which will be allowed to consume all available
753
- memory.
754
- """
755
- # Our normal default
756
- default_memory_limit = "7g"
757
-
758
- # Only run on our servers
759
- if self .RTD_IS_PRODUCTION :
760
- total_memory , memory_limit = self ._get_build_memory_limit ()
761
-
762
- memory_limit = memory_limit or default_memory_limit
763
- log .info (
764
- "Using dynamic build limits." ,
765
- hostname = socket .gethostname (),
766
- memory = memory_limit ,
767
- )
768
- return memory_limit
769
-
770
771
# Allauth
771
772
ACCOUNT_ADAPTER = "readthedocs.core.adapters.AccountAdapter"
772
773
SOCIALACCOUNT_ADAPTER = 'readthedocs.core.adapters.SocialAccountAdapter'
0 commit comments