This commit is contained in:
Lex Berezhny 2020-09-29 07:52:28 -04:00
parent 838cc60161
commit ec2f6c6b80

View file

@ -7,7 +7,6 @@ from binascii import hexlify
from collections import defaultdict from collections import defaultdict
from dataclasses import dataclass from dataclasses import dataclass
from contextvars import ContextVar from contextvars import ContextVar
from concurrent.futures.thread import ThreadPoolExecutor
from typing import Tuple, List, Union, Callable, Any, Awaitable, Iterable, Dict, Optional from typing import Tuple, List, Union, Callable, Any, Awaitable, Iterable, Dict, Optional
from datetime import date from datetime import date
from prometheus_client import Gauge, Counter, Histogram from prometheus_client import Gauge, Counter, Histogram
@ -18,6 +17,12 @@ from .transaction import Transaction, Output, OutputScript, TXRefImmutable, Inpu
from .constants import TXO_TYPES, CLAIM_TYPES from .constants import TXO_TYPES, CLAIM_TYPES
from .util import date_to_julian_day from .util import date_to_julian_day
from concurrent.futures.thread import ThreadPoolExecutor # pylint: disable=wrong-import-order
if platform.system() == 'Windows' or 'ANDROID_ARGUMENT' or 'KIVY_BUILD' in os.environ:
from concurrent.futures.thread import ThreadPoolExecutor as ReaderExecutorClass # pylint: disable=reimported
else:
from concurrent.futures.process import ProcessPoolExecutor as ReaderExecutorClass
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
sqlite3.enable_callback_tracebacks(True) sqlite3.enable_callback_tracebacks(True)
@ -61,13 +66,6 @@ def run_read_only_fetchone(sql, params):
raise raise
if platform.system() == 'Windows' or 'ANDROID_ARGUMENT' or 'KIVY_BUILD' in os.environ:
ReaderExecutorClass = ThreadPoolExecutor
else:
from concurrent.futures.process import ProcessPoolExecutor
ReaderExecutorClass = ProcessPoolExecutor
class AIOSQLite: class AIOSQLite:
reader_executor: ReaderExecutorClass reader_executor: ReaderExecutorClass