dominiktraxl/pykrakenapi

Unclosed socket error

rracinskij opened this issue · 6 comments

Hi,
after execution of a Python script that tests pykrakenapi together with some other Web3.py code I get an error:
sys:1: ResourceWarning: unclosed <socket.socket fd=7, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('192.168.1.64', 54209), raddr=('104.16.211.191', 443)>
What should be done to avoid it? Thanks.

I've never seen such an error with pykrakenapi : is it really related ?

Yes, I was also unsure, but the IP looks to be related with Kraken.

I've never seen this error using pykrakenapi. Could you provide the code that produces this error? Maybe then I can try to help. But generally speaking, pykrakenapi is not dealing with the interface to the Kraken API. It's using krakenex to do that, so you might want to ask there: https://github.com/veox/python3-krakenex

The code is:

import krakenex
from pykrakenapi import KrakenAPI
from web3.providers.eth_tester import EthereumTesterProvider
from web3 import Web3

w3 = Web3(EthereumTesterProvider())

api = krakenex.API()
api.load_key('ABT_SC_test_key.key')
k = KrakenAPI(api, tier=2)

bal = k.get_account_balance()
print(bal)

Defining w3 and running Kraken API requests in the same script results in the error above. Everything goes well separately.

Sorry, I've never used web3, I don't know how it possibly interferes with requests. You could try to ask here: https://github.com/veox/python3-krakenex - this is where the actual requests are implemented.

Thank you, I'll close the issue.