0xPlaygrounds / 0xPlaygrounds/subgrounds

How to close the SSL connection correctly?

オープン
#52 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
bug question
主要言語
Python
スター
73
フォーク
12
PR マージ指標
30日以内にマージされた PR はありません

説明

Is there a method that I can close the SSL connection which is build by Subgrounds? I checked the API document which doesn't have a similar content.

I tried to close it with contextlib, but it also can't solve this problem.

```
# Import the Subgrounds library

from subgrounds import Subgrounds
from contextlib import closing
import os

def another_function():

# load_dotenv()
graph_api_key = ''
# Create a new Subgrounds object
with closing(Subgrounds()) as sg:

# Load the Uniswap v3 subgraph using a specific API endpoint
uni = sg.load_subgraph(
f'https://gateway.thegraph.com/api/{graph_api_key}/subgraphs/id/ELUcwgpm14LKPLrBRuVvPvNKHQ9HvwmtKgKSH6123cr7')
#
# Query the financialsDailySnapshots endpoint with a specified order, limit, and filter criteria
latest_snapshots = uni.Query.financialsDailySnapshots(
orderBy=uni.FinancialsDailySnapshot.timestamp,
orderDirection='desc',
first=1,
)

# Convert the query results to a Pandas dataframe and extract the first row
res = sg.query_df(latest_snapshots).squeeze()
pass
print("Another function")

another_function()
```

which would give me two error message:

> AttributeError: 'Subgrounds' object has no attribute 'close'
I can't close it like this.

> sys:1: ResourceWarning: unclosed

That's the real problem. When the program end, PY just simply terminate everything and trigger this error. I can read data from this, but how to safely close the connection?

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Look at the Subgrounds class in subgrounds/subgrounds.py to see how connections are managed. Check if there's a session or client that needs closing. The error mentions an unclosed ssl.SSLSocket, so examine the HTTP client used (likely requests or aiohttp). Find where the connection is established and ensure a proper cleanup method exists or can be added. Test by running the provided script after modifications.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
graphql, python
領域
api, backend
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。