2022-05-01 09:31:18 +02:00
|
|
|
# standard imports
|
|
|
|
import logging
|
2022-05-01 09:55:51 +02:00
|
|
|
import time
|
2022-05-01 09:31:18 +02:00
|
|
|
|
2022-03-14 22:40:20 +01:00
|
|
|
# external imports
|
|
|
|
from chainqueue import Store as QueueStore
|
|
|
|
|
2022-05-01 08:58:52 +02:00
|
|
|
# local imports
|
2022-05-02 11:59:13 +02:00
|
|
|
from chaind.lock import StoreLock
|
2022-05-01 08:58:52 +02:00
|
|
|
|
2022-05-01 09:31:18 +02:00
|
|
|
logg = logging.getLogger(__name__)
|
|
|
|
|
2022-03-14 22:40:20 +01:00
|
|
|
|
|
|
|
class ChaindAdapter:
|
|
|
|
|
2022-05-04 07:37:51 +02:00
|
|
|
def __init__(self, chain_spec, state_store, index_store, counter_store, cache_adapter, dispatcher, cache=None, pending_retry_threshold=0, error_retry_threshold=0, store_sync=True):
|
2022-03-15 09:28:10 +01:00
|
|
|
self.cache_adapter = cache_adapter
|
2022-03-14 22:40:20 +01:00
|
|
|
self.dispatcher = dispatcher
|
2022-05-02 11:59:13 +02:00
|
|
|
store_lock = StoreLock()
|
|
|
|
while True:
|
2022-05-01 08:58:52 +02:00
|
|
|
try:
|
2022-05-04 07:37:51 +02:00
|
|
|
self.store = QueueStore(chain_spec, state_store, index_store, counter_store, cache=cache, sync=store_sync)
|
2022-05-01 08:58:52 +02:00
|
|
|
break
|
|
|
|
except FileNotFoundError as e:
|
2022-05-01 09:55:51 +02:00
|
|
|
logg.debug('queuestore instantiation failed, possible race condition (will try again): {}'.format(e))
|
2022-05-02 11:59:13 +02:00
|
|
|
store_lock.again()
|
2022-05-01 08:58:52 +02:00
|
|
|
continue
|