Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hot fix 0.14.2 #26

Merged
merged 2 commits into from
Sep 18, 2020
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
29 changes: 21 additions & 8 deletions examples/deribit/check_is_connected.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,34 @@

conn = Deribit()

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

loop = asyncio.get_event_loop()

def close():
print("Check connection before closing", conn.is_connected())
asyncio.ensure_future(conn.stop())
i = 0
def check():
global i
i += 1
print("Check connection ", conn.is_connected())
loop.call_later(1, close, i < 2)

def run():
print("Is connected before run_receiver() ", conn.is_connected())
asyncio.ensure_future(conn.run_receiver())
loop.call_later(1, check)

loop = asyncio.get_event_loop()
def close(restart: bool = True):
print("Is connection before closing", conn.is_connected())
asyncio.ensure_future(conn.stop())
if restart:
loop.call_later(2, run)

def stop():
loop.call_later(1, loop.stop)

loop.call_later(1, close)
loop.call_later(10, stop)
loop.call_soon(run)

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

Expand Down
6 changes: 5 additions & 1 deletion ssc2ce/common/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,11 @@ async def public_get(self, request_path, params=None):

async def stop(self):
await self.ws.close()
await self._session.close()

if self.__internal_session and self.__session:
await self.__session.close()
self.__session = None
self.__is_session = False

def is_connected(self) -> bool:
if self.ws is None:
Expand Down