def METHOD_NAME(cls, subject: _TConsSubject) -> None:
    trans_context = subject._trans_context_manager
    if trans_context:
        if not trans_context._transaction_is_active():
            raise exc.InvalidRequestError(
                "Can't operate on closed transaction inside context "
                "manager.  Please complete the context manager "
                "before emitting further commands."
            )