-
Notifications
You must be signed in to change notification settings - Fork 229
Description
Versions
OS: Windows
Python: 3.6.2
krakenex: v1.0.0c1
What are you trying to achieve?
Close an open connection after timeout
# code sample
def query_order(k, txid):
options = {'txid':''}
options['txid'] = txid
try:
print ("querying open orders")
values = k.query_private('QueryOrders',options)
print ("result")
print (values)
return values
except:
print ("query_pair: Unexpected error:", sys.exc_info()[0])
# probably a timeout, sleep 60 seconds and try again
k.conn = None
time.sleep(60)
return NoneWhat do you expect to happen?
I would like to close/reset the krakenex connection. Since I am running a lot in some sort of endless loop of timeouts, which, miraculously always get resorted after I restart my code.
Now I thought the k.conn = None would sort that issue.
It does, kind of, it creates a new connection and the timeout issue disappears.
However if the bot runs long enough, which now happened after 16h, the shell had so many instances that I was getting socket errors until I closed the entire shell and started in a fresh shell.
My best attempt was k.conn.close() but the below code returns:
# code sample
k.query_public('Ticker',dict([('pair', 'XXBTZEUR')]))
print (k.conn)
k.conn.close()
print (k.conn)
k.query_public('Ticker',dict([('pair', 'XXBTZEUR')]))
print (k.conn)# message
<krakenex.connection.Connection object at 0x036607B0>
<krakenex.connection.Connection object at 0x036607B0>
<krakenex.connection.Connection object at 0x036607B0>I don't know, is it really creating a new connection at the next query? if I use my shitty k.conn = None method I get a new memory imprint.
No idea how to handle those infinite timeouts, or well, reset krakenex connection without creating a dead instance.