INNER CODE UNIT · Python

_reset_log_context

arc53/DocsGPT · docsgpt/app.py:332

def _reset_log_context(_exc):
    # SSE streams keep yielding after teardown fires, but a2wsgi runs each
    # request inside ``copy_context().run(...)``, so this reset doesn't
    # leak into the stream's view of the context.
    token = getattr(request, _LOG_CTX_TOKEN_ATTR, None)
    if token is not None:
        # Flask >= 3.1.2 tears a stream_with_context request down twice: once
        # when the view returns, once when the generator is finalized. Clear
        # the token first — resetting one twice raises RuntimeError.
        setattr(request, _LOG_CTX_TOKEN_ATTR, None)
        log_context.reset(token)


@app.before_request
def enforce_stt_request_size_limits():
    if request.method == "OPTIONS":
        return None
    if should_reject_stt_request(request.path, request.content_length):

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…