summaryrefslogtreecommitdiff
path: root/siridb/connector/lib/client.py
diff options
context:
space:
mode:
Diffstat (limited to 'siridb/connector/lib/client.py')
-rw-r--r--siridb/connector/lib/client.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/siridb/connector/lib/client.py b/siridb/connector/lib/client.py
index b3ec636..09044a2 100644
--- a/siridb/connector/lib/client.py
+++ b/siridb/connector/lib/client.py
@@ -6,13 +6,13 @@ SiriDB Client for python => 3.5 using asyncio.
'''
import asyncio
import functools
-import logging
import random
from .protocol import _SiriDBProtocol
from .connection import SiriDBAsyncConnection
from .exceptions import AuthenticationError
from .exceptions import ServerError
from .exceptions import PoolError
+from .logging import logger as logging
class _SiriDBClientProtocol(_SiriDBProtocol):
@@ -164,6 +164,11 @@ class SiriDBClient:
'''Can be used to check if close() has been called.'''
return not self._retry_connect
+ @property
+ def connected(self):
+ '''Can be used to check the client has any active connections'''
+ return any(connection.connected for connection in self._connections)
+
@staticmethod
def _log_connect_result(result):
for r in result:
@@ -225,7 +230,7 @@ class SiriDBClient:
# only try unavailable once
try_unavailable = False
- async def _connect(self, timeout=None):
+ async def _connect(self, timeout=None): # the one that actually connects
tasks = [
connection.connect(
self._username,
@@ -247,7 +252,7 @@ class SiriDBClient:
self._log_connect_result(result)
return result
- async def _connect_loop(self):
+ async def _connect_loop(self): # the one that looks for connections
sleep = 1
try:
while [connection