Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions examples/deribit/check_is_connected.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import asyncio
import json
from ssc2ce import Deribit

conn = Deribit()

print("Is connected after init", conn.is_connected())


def close():
print("Check connection before closing", conn.is_connected())
asyncio.ensure_future(conn.stop())


loop = asyncio.get_event_loop()


loop.call_later(1, close)

try:
loop.run_until_complete(conn.run_receiver())
except KeyboardInterrupt:
print("Application closed by KeyboardInterrupt.")


print("Is connected before exit", conn.is_connected())
2 changes: 1 addition & 1 deletion examples/deribit/deribit_private.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ async def do_something_after_login(self):
async def printer(self, **kwargs):
self.logger.info(f"{repr(kwargs)}")

@ staticmethod
@staticmethod
def resolve_route(value, routes):
key, handler = None, None
for key, handler in routes:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setuptools.setup(
name='ssc2ce',
version="0.14.0",
version="0.14.1",
author='Oleg Nedbaylo',
author_email='olned64@gmail.com',
description='A Set of Simple Connectors for access To Cryptocurrency Exchanges',
Expand Down
6 changes: 6 additions & 0 deletions ssc2ce/common/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,9 @@ async def public_get(self, request_path, params=None):
async def stop(self):
await self.ws.close()
await self._session.close()

def is_connected(self) -> bool:
if self.ws is None:
return False

return not self.ws.closed
6 changes: 0 additions & 6 deletions ssc2ce/deribit/deribit.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,6 @@ def __init__(self,
def close(self):
super()._close()

async def stop(self):
"""
Close connection and break the receiver loop
:return:
"""
await self.ws.close()

async def send_public(self, request: dict, callback=None, logging_it: bool = True) -> int:
"""
Expand Down