constants.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # Contains code from https://github.com/MagicStack/uvloop/tree/v0.16.0
  2. # SPDX-License-Identifier: PSF-2.0 AND (MIT OR Apache-2.0)
  3. # SPDX-FileCopyrightText: Copyright (c) 2015-2021 MagicStack Inc. http://magic.io
  4. import enum
  5. # After the connection is lost, log warnings after this many write()s.
  6. LOG_THRESHOLD_FOR_CONNLOST_WRITES = 5
  7. # Seconds to wait before retrying accept().
  8. ACCEPT_RETRY_DELAY = 1
  9. # Number of stack entries to capture in debug mode.
  10. # The larger the number, the slower the operation in debug mode
  11. # (see extract_stack() in format_helpers.py).
  12. DEBUG_STACK_DEPTH = 10
  13. # Number of seconds to wait for SSL handshake to complete
  14. # The default timeout matches that of Nginx.
  15. SSL_HANDSHAKE_TIMEOUT = 60.0
  16. # Number of seconds to wait for SSL shutdown to complete
  17. # The default timeout mimics lingering_time
  18. SSL_SHUTDOWN_TIMEOUT = 30.0
  19. # Used in sendfile fallback code. We use fallback for platforms
  20. # that don't support sendfile, or for TLS connections.
  21. SENDFILE_FALLBACK_READBUFFER_SIZE = 1024 * 256
  22. FLOW_CONTROL_HIGH_WATER_SSL_READ = 256 # KiB
  23. FLOW_CONTROL_HIGH_WATER_SSL_WRITE = 512 # KiB
  24. # Default timeout for joining the threads in the threadpool
  25. THREAD_JOIN_TIMEOUT = 300
  26. # The enum should be here to break circular dependencies between
  27. # base_events and sslproto
  28. class _SendfileMode(enum.Enum):
  29. UNSUPPORTED = enum.auto()
  30. TRY_NATIVE = enum.auto()
  31. FALLBACK = enum.auto()