• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

spesmilo / electrum / 35374450208

18 Sep 2026 05:27PM UTC coverage: 69.868% (-0.03%) from 69.898%
35374450208

push

github

web-flow
Merge pull request #10975 from f321x/friendlier_strings_qt_tx_dialog

qt: TxEditor: friendlier strings for send change to lightning

1 of 17 new or added lines in 1 file covered. (5.88%)

11 existing lines in 4 files now uncovered.

27285 of 39052 relevant lines covered (69.87%)

0.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

77.59
/electrum/sql_db.py
1
import os
1✔
2
import queue
1✔
3
import threading
1✔
4
import asyncio
1✔
5
import sqlite3
1✔
6

7
from .logging import Logger
1✔
8
from .util import test_read_write_permissions
1✔
9

10

11
def sql(func):
1✔
12
    """wrapper for sql methods
13

14
    returns an awaitable asyncio.Future
15
    """
16
    def wrapper(self: 'SqlDB', *args, **kwargs):
1✔
17
        assert threading.current_thread() != self.sql_thread
1✔
18
        f = self.asyncio_loop.create_future()
1✔
19
        self.db_requests.put((f, func, args, kwargs))
1✔
20
        return f
1✔
21
    return wrapper
1✔
22

23

24
class SqlDB(Logger):
1✔
25

26
    def __init__(self, asyncio_loop: asyncio.BaseEventLoop, path, commit_interval=None):
1✔
27
        Logger.__init__(self)
1✔
28
        self.asyncio_loop = asyncio_loop
1✔
29
        self.stopping = False
1✔
30
        self.stopped_event = asyncio.Event()
1✔
31
        self.path = path
1✔
32
        test_read_write_permissions(path)
1✔
33
        self.commit_interval = commit_interval
1✔
34
        self.db_requests = queue.Queue()
1✔
35
        self.sql_thread = threading.Thread(target=self.run_sql)
1✔
36
        self.sql_thread.start()
1✔
37

38
    def stop(self):
1✔
39
        self.stopping = True
1✔
40

41
    def filesize(self):
1✔
42
        return os.stat(self.path).st_size
×
43

44
    def run_sql(self):
1✔
45
        self.logger.info("SQL thread started")
1✔
46
        self.conn = sqlite3.connect(self.path)
1✔
47
        self.logger.info("Creating database")
1✔
48
        self.create_database()
1✔
49
        i = 0
1✔
50
        while not self.stopping and self.asyncio_loop.is_running():
1✔
51
            try:
1✔
52
                future, func, args, kwargs = self.db_requests.get(timeout=0.1)
1✔
53
            except queue.Empty:
1✔
54
                continue
1✔
UNCOV
55
            try:
×
UNCOV
56
                result = func(self, *args, **kwargs)
×
57
            except BaseException as e:
×
58
                self.asyncio_loop.call_soon_threadsafe(future.set_exception, e)
×
59
                continue
×
UNCOV
60
            if not future.cancelled():
×
UNCOV
61
                self.asyncio_loop.call_soon_threadsafe(future.set_result, result)
×
62
            # note: in sweepstore session.commit() is called inside
63
            # the sql-decorated methods, so committing to disk is awaited
UNCOV
64
            if self.commit_interval:
×
UNCOV
65
                i = (i + 1) % self.commit_interval
×
UNCOV
66
                if i == 0:
×
67
                    self.conn.commit()
×
68
        # write
69
        self.conn.commit()
1✔
70
        self.conn.close()
1✔
71

72
        self.logger.info("SQL thread terminated")
1✔
73
        self.asyncio_loop.call_soon_threadsafe(self.stopped_event.set)
1✔
74

75
    def create_database(self):
1✔
76
        raise NotImplementedError()
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc