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 5import enum 6 7# After the connection is lost, log warnings after this many write()s. 8LOG_THRESHOLD_FOR_CONNLOST_WRITES = 5 9 10# Seconds to wait before retrying accept(). 11ACCEPT_RETRY_DELAY = 1 12 13# Number of stack entries to capture in debug mode. 14# The larger the number, the slower the operation in debug mode 15# (see extract_stack() in format_helpers.py). 16DEBUG_STACK_DEPTH = 10 17 18# Number of seconds to wait for SSL handshake to complete 19# The default timeout matches that of Nginx. 20SSL_HANDSHAKE_TIMEOUT = 60.0 21 22# Number of seconds to wait for SSL shutdown to complete 23# The default timeout mimics lingering_time 24SSL_SHUTDOWN_TIMEOUT = 30.0 25 26# Used in sendfile fallback code. We use fallback for platforms 27# that don't support sendfile, or for TLS connections. 28SENDFILE_FALLBACK_READBUFFER_SIZE = 1024 * 256 29 30FLOW_CONTROL_HIGH_WATER_SSL_READ = 256 # KiB 31FLOW_CONTROL_HIGH_WATER_SSL_WRITE = 512 # KiB 32 33# Default timeout for joining the threads in the threadpool 34THREAD_JOIN_TIMEOUT = 300 35 36# The enum should be here to break circular dependencies between 37# base_events and sslproto 38class _SendfileMode(enum.Enum): 39 UNSUPPORTED = enum.auto() 40 TRY_NATIVE = enum.auto() 41 FALLBACK = enum.auto() 42