Get proxy settings from CoreSettings JSON data with fallback to defaults (cached)
(cls)
| 21 | |
| 22 | @classmethod |
| 23 | def get_proxy_settings(cls): |
| 24 | """Get proxy settings from CoreSettings JSON data with fallback to defaults (cached)""" |
| 25 | # Check if cache is still valid |
| 26 | now = time.time() |
| 27 | if cls._proxy_settings_cache is not None and (now - cls._proxy_settings_cache_time) < cls._proxy_settings_cache_ttl: |
| 28 | return cls._proxy_settings_cache |
| 29 | |
| 30 | # Cache miss or expired - fetch from database |
| 31 | try: |
| 32 | from core.models import CoreSettings |
| 33 | settings = CoreSettings.get_proxy_settings() |
| 34 | cls._proxy_settings_cache = settings |
| 35 | cls._proxy_settings_cache_time = now |
| 36 | return settings |
| 37 | |
| 38 | except Exception: |
| 39 | # Return defaults if database query fails |
| 40 | return { |
| 41 | "buffering_timeout": 15, |
| 42 | "buffering_speed": 1.0, |
| 43 | "redis_chunk_ttl": 60, |
| 44 | "channel_shutdown_delay": 0, |
| 45 | "channel_init_grace_period": 60, |
| 46 | "channel_client_wait_period": 5, |
| 47 | "new_client_behind_seconds": 5, |
| 48 | } |
| 49 | |
| 50 | finally: |
| 51 | # Always close the connection after reading settings |
| 52 | try: |
| 53 | connection.close() |
| 54 | except Exception: |
| 55 | pass |
| 56 | |
| 57 | @classmethod |
| 58 | def get_redis_chunk_ttl(cls): |