mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
wait till timeout added to rethinkdb connection
This commit is contained in:
parent
cc66d5aaa5
commit
5edac3f4ee
@ -1,4 +1,6 @@
|
|||||||
import rethinkdb as r
|
import rethinkdb as r
|
||||||
|
import time
|
||||||
|
import bigchaindb
|
||||||
|
|
||||||
from bigchaindb.backend.connection import Connection
|
from bigchaindb.backend.connection import Connection
|
||||||
from bigchaindb.backend.exceptions import ConnectionError, OperationError
|
from bigchaindb.backend.exceptions import ConnectionError, OperationError
|
||||||
@ -38,8 +40,16 @@ class RethinkDBConnection(Connection):
|
|||||||
:exc:`rethinkdb.ReqlDriverError`: After
|
:exc:`rethinkdb.ReqlDriverError`: After
|
||||||
:attr:`~.RethinkDBConnection.max_tries`.
|
:attr:`~.RethinkDBConnection.max_tries`.
|
||||||
"""
|
"""
|
||||||
|
connected=False
|
||||||
try:
|
dbconf = bigchaindb.config['database']
|
||||||
return r.connect(host=self.host, port=self.port, db=self.dbname)
|
timeout = dbconf['connection_timeout']
|
||||||
except r.ReqlDriverError as exc:
|
end_time = time.time()*1000 + timeout
|
||||||
raise ConnectionError from exc
|
while not connected:
|
||||||
|
try:
|
||||||
|
rconn=r.connect(host=self.host, port=self.port, db=self.dbname)
|
||||||
|
connected=True
|
||||||
|
except r.ReqlDriverError as exc:
|
||||||
|
if time.time()*1000 > end_time:
|
||||||
|
raise ConnectionError from exc
|
||||||
|
pass
|
||||||
|
return rconn
|
||||||
|
Loading…
x
Reference in New Issue
Block a user