CliDyn / climsight

prototype of a system that provide local climate information

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ResourceWarning: unclosed <ssl.SSLSocket> during SSL connections

AntoniaJost opened this issue · comments

Description

I encountered a ResourceWarning related to an unclosed <ssl.SSLSocket> when using SSL connections. The warning message appears as follows:

sys:1: ResourceWarning: unclosed <ssl.SSLSocket fd=19, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('10.15.29.62', 55038), raddr=('104.18.7.192', 443)>
ResourceWarning: Enable tracemalloc to get the object allocation traceback

Steps to Reproduce

  1. Activate the environment
  2. Run 'python src/climsight/evaluation.py'

Expected Behavior

No ResourceWarning should appear, indicating that all SSL connections are properly closed.

Actual Behavior

A ResourceWarning appears, indicating that an SSL socket remains unclosed. (I did not enable the tracemalloc yet.)

Environment

  • Python version: 3.10.14
  • Operating System: Ubuntu 22.04.4 LTS

Additional Information

I enabled tracemalloc to get the object allocation traceback, which returned the following resultt:

/home/anjost001/Documents/AWI/climsight/src/climsight/evaluation.py:273: ResourceWarning: unclosed <ssl.SSLSocket fd=19, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('192.168.178.25', 42024), raddr=('104.18.6.192', 443)>
  gc.collect()
Object allocated at (most recent call last):
  File "/home/anjost001/anaconda3/envs/climsight/lib/python3.10/ssl.py", lineno 1034
    self = cls.__new__(cls, **kwargs)
[ Top 10 ]
<frozen importlib._bootstrap_external>:672: size=7560 KiB, count=71302, average=109 B
/home/anjost001/anaconda3/envs/climsight/lib/python3.10/site-packages/matplotlib/transforms.py:198: size=3695 KiB, count=41733, average=91 B
<frozen importlib._bootstrap>:241: size=3282 KiB, count=21549, average=156 B
/home/anjost001/anaconda3/envs/climsight/lib/python3.10/site-packages/matplotlib/patches.py:764: size=2478 KiB, count=1149, average=2208 B
/home/anjost001/anaconda3/envs/climsight/lib/python3.10/site-packages/matplotlib/transforms.py:122: size=2238 KiB, count=34982, average=66 B
/home/anjost001/anaconda3/envs/climsight/lib/python3.10/site-packages/pandas/core/array_algos/take.py:157: size=1874 KiB, count=20, average=93.7 KiB
/home/anjost001/anaconda3/envs/climsight/lib/python3.10/site-packages/matplotlib/text.py:314: size=1615 KiB, count=749, average=2208 B
/home/anjost001/anaconda3/envs/climsight/lib/python3.10/site-packages/matplotlib/lines.py:389: size=1581 KiB, count=733, average=2208 B
/home/anjost001/anaconda3/envs/climsight/lib/python3.10/linecache.py:137: size=1009 KiB, count=9956, average=104 B
/home/anjost001/anaconda3/envs/climsight/lib/python3.10/site-packages/matplotlib/transforms.py:197: size=978 KiB, count=13912, average=72 B

However, I was not able to solve the issue based on that.