Skip to content

SNOW-2147253: pyopenssl "Attempting to mutate a Context after a Connection was created" deprecation warning #2353

Open
@AddisonDunn

Description

@AddisonDunn

Python version

Python 3.12.3

Operating system and processor architecture

macOS-15.5-x86_64-i386-64bit-Mach-O

Installed packages

altair==5.5.0
annotated-types==0.7.0
anyio==4.9.0
appnope==0.1.4
argon2-cffi==23.1.0
argon2-cffi-bindings==21.2.0
arrow==1.3.0
asn1crypto==1.5.1
astroid==3.3.9
asttokens==3.0.0
async-lru==2.0.5
attrs==25.3.0
babel==2.17.0
backoff==2.2.1
bcrypt==4.3.0
beautifulsoup4==4.13.4
bleach==6.2.0
blinker==1.9.0
boto3==1.38.9
botocore==1.38.9
cachetools==5.5.2
certifi==2025.4.26
cffi==1.17.1
charset-normalizer==3.4.2
click==8.1.8
cloudevents==1.11.0
comm==0.2.2
coverage==7.8.0
cryptography==44.0.3
debugpy==1.8.14
decorator==5.2.1
defusedxml==0.7.1
deprecation==2.1.0
dill==0.4.0
distro==1.9.0
et_xmlfile==2.0.0
executing==2.2.0
fastjsonschema==2.21.1
filelock==3.18.0
flake8==7.2.0
flake8-unused-arguments==0.0.13
Flask==3.1.0
fqdn==1.5.1
functions-framework==3.8.3
gitdb==4.0.12
GitPython==3.1.44
google-api-core==2.24.2
google-api-python-client==2.171.0
google-api-python-client-stubs==1.29.0
google-auth==2.40.3
google-auth-httplib2==0.2.0
google-auth-oauthlib==1.2.2
google-cloud-core==2.4.3
google-cloud-run==0.10.18
google-cloud-storage==3.1.0
google-crc32c==1.7.1
google-resumable-media==2.7.2
googleapis-common-protos==1.70.0
greenlet==3.2.1
grpc-google-iam-v1==0.14.2
grpcio==1.72.0rc1
grpcio-status==1.72.0rc1
gspread==6.2.1
gunicorn==23.0.0
h11==0.16.0
httpcore==1.0.9
httplib2==0.22.0
httpx==0.28.1
idna==3.10
iniconfig==2.1.0
ipykernel==6.29.5
ipython==9.2.0
ipython-genutils==0.2.0
ipython_pygments_lexers==1.1.1
ipywidgets==8.1.7
isoduration==20.11.0
isort==6.0.1
itsdangerous==2.2.0
jaraco.classes==3.4.0
jaraco.context==6.0.1
jaraco.functools==4.1.0
jedi==0.19.2
Jinja2==3.1.6
jmespath==1.0.1
json5==0.12.0
jsonpointer==3.0.0
jsonschema==4.23.0
jsonschema-specifications==2025.4.1
jupysql==0.11.1
jupysql-plugin==0.4.5
jupyter==1.1.1
jupyter-console==6.6.3
jupyter-events==0.12.0
jupyter-lsp==2.2.5
jupyter_client==8.6.3
jupyter_core==5.7.2
jupyter_server==2.15.0
jupyter_server_terminals==0.5.3
jupyterlab==4.4.2
jupyterlab_pygments==0.3.0
jupyterlab_server==2.27.3
jupyterlab_widgets==3.0.15
keyring==25.6.0
MarkupSafe==3.0.2
matplotlib-inline==0.1.7
mccabe==0.7.0
mistune==3.1.3
more-itertools==10.7.0
mypy==1.16.0
mypy_extensions==1.1.0
narwhals==1.38.0
nbclient==0.10.2
nbconvert==7.16.6
nbformat==5.10.4
nest-asyncio==1.6.0
nodeenv==1.9.1
notebook==7.4.2
notebook_shim==0.2.4
numpy==2.3.0
oauthlib==3.2.2
openpyxl==3.1.5
ordered-set==4.1.0
overrides==7.7.0
packaging==24.2
pandas==2.3.0
pandas-stubs==2.2.3.250527
pandera==0.24.0
pandocfilters==1.5.1
paramiko==3.5.1
parso==0.8.4
pathspec==0.12.1
pexpect==4.9.0
pillow==11.2.1
platformdirs==4.3.7
ploomber-core==0.2.26
pluggy==1.5.0
posthog==4.0.1
prettytable==3.16.0
prometheus_client==0.21.1
prompt_toolkit==3.0.51
proto-plus==1.26.1
protobuf==6.31.1
psutil==7.0.0
ptyprocess==0.7.0
pure_eval==0.2.3
pyarrow==18.1.0
pyasn1==0.6.1
pyasn1_modules==0.4.2
pycodestyle==2.13.0
pycparser==2.22
pydantic==2.11.5
pydantic_core==2.33.2
pydeck==0.9.1
pyflakes==3.3.2
Pygments==2.19.1
PyJWT==2.10.1
pylint==3.3.7
PyNaCl==1.5.0
pyOpenSSL==25.0.0
pyparsing==3.2.3
pyright==1.1.401
pytest==8.4.0
pytest-check==2.5.3
pytest-cov==6.1.1
pytest-socket==0.7.0
python-dateutil==2.9.0.post0
python-dotenv==1.1.0
python-json-logger==3.3.0
pytz==2025.2
PyYAML==6.0.2
pyzmq==26.4.0
referencing==0.36.2
requests==2.32.4
requests-oauthlib==2.0.0
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rpds-py==0.24.0
rsa==4.9.1
s3transfer==0.12.0
schemachange==4.0.1
Send2Trash==1.8.3
setuptools==80.3.1
six==1.17.0
smmap==5.0.2
sniffio==1.3.1
snowflake-connector-python==3.15.0
snowflake-sqlalchemy==1.7.3
sortedcontainers==2.4.0
soupsieve==2.7
SQLAlchemy==2.0.41
sqlglot==26.16.4
sqlparse==0.5.3
stack-data==0.6.3
streamlit==1.45.1
structlog==24.1.0
tableauserverclient==0.38
tenacity==9.1.2
terminado==0.18.1
tinycss2==1.4.0
toml==0.10.2
tomlkit==0.13.3
tornado==6.4.2
traitlets==5.14.3
typeguard==4.4.3
types-beautifulsoup4==4.12.0.20250204
types-html5lib==1.1.11.20241018
types-httplib2==0.22.0.20250401
types-openpyxl==3.1.5.20250602
types-paramiko==3.5.0.20250516
types-python-dateutil==2.9.0.20241206
types-pytz==2025.2.0.20250326
types-PyYAML==6.0.12.20250516
types-requests==2.32.0.20250602
typing-inspect==0.9.0
typing-inspection==0.4.1
typing_extensions==4.14.0
tzdata==2025.2
uri-template==1.3.0
uritemplate==4.1.1
urllib3==2.4.0
vulture==2.14
watchdog==6.0.0
wcwidth==0.2.13
webcolors==24.11.1
webencodings==0.5.1
websocket-client==1.8.0
Werkzeug==3.1.3
widgetsnbextension==4.0.14

What did you do?

# Run command "SHOW COLUMNS IN ACCOUNT" in a connection. Here is our connector function:
@contextmanager
def get_connection(
    env: EnvOption = "DEV",
    role: str | None = None,
    warehouse: str | None = None,
):
    """Yields the Snowflake connection https://docs.snowflake.com/en/developer-guide/python-connector/python-connector-connect#connecting-using-the-connections-toml-file"""

    conn_name = f"cologov-{env.lower()}"
    with connect(
        connection_name=conn_name,
        role=role,
        warehouse=warehouse,
    ) as conn:
        yield GraupelConnection(conn)

What did you expect to see?

As of 5/17/2025 pyOpenSSL has marked certain functions as deprecated: https://pypi.org/project/pyOpenSSL/

In our case the deprecated function used by snowflake connector is load_verify_locations:

/azp/_work/1/s/.venv/lib/python3.12/site-packages/snowflake/connector/vendored/urllib3/contrib/pyopenssl.py:458: DeprecationWarning: Attempting to mutate a Context after a Connection was created. In the future, this will raise an exception
    self._ctx.load_verify_locations(cafile, capath)

Can you set logging to DEBUG and collect the logs?

import logging
import os

for logger_name in ('snowflake.connector',):
    logger = logging.getLogger(logger_name)
    logger.setLevel(logging.DEBUG)
    ch = logging.StreamHandler()
    ch.setLevel(logging.DEBUG)
    ch.setFormatter(logging.Formatter('%(asctime)s - %(threadName)s %(filename)s:%(lineno)d - %(funcName)s() - %(levelname)s - %(message)s'))
    logger.addHandler(ch)

Metadata

Metadata

Labels

enhancementThe issue is a request for improvement or a new featurestatus-triage_doneInitial triage done, will be further handled by the driver team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions