tangled
alpha
login
or
join now
edavis.dev
/
bsky-tools
0
fork
atom
this repo has no description
0
fork
atom
overview
issues
pulls
pipelines
feeds: use in_transaction attribute of database connection
Eric Davis
2 years ago
73d90bdb
96333916
+2
-11
3 changed files
expand all
collapse all
unified
split
feeds
__init__.py
popular.py
rapidfire.py
+2
-7
feeds/__init__.py
···
1
1
from datetime import datetime, timezone, timedelta
2
2
3
3
class BaseFeed:
4
4
-
def __init__(self):
5
5
-
self.in_transaction = False
6
6
-
7
4
def process_commit(self, commit):
8
5
raise NotImplementedError
9
6
···
51
48
return utc_now
52
49
53
50
def transaction_begin(self, db):
54
54
-
if not self.in_transaction:
51
51
+
if not db.in_transaction:
55
52
db.execute('BEGIN')
56
56
-
self.in_transaction = True
57
53
58
54
def transaction_commit(self, db):
59
59
-
if self.in_transaction:
55
55
+
if db.in_transaction:
60
56
db.execute('COMMIT')
61
61
-
self.in_transaction = False
62
57
63
58
def wal_checkpoint(self, db, mode='PASSIVE'):
64
59
db.pragma(f'wal_checkpoint({mode})')
-2
feeds/popular.py
···
9
9
FEED_URI = 'at://did:plc:4nsduwlpivpuur4mqkbfvm6a/app.bsky.feed.generator/popular'
10
10
11
11
def __init__(self):
12
12
-
super().__init__()
13
13
-
14
12
self.db_cnx = apsw.Connection('db/popular.db')
15
13
self.db_cnx.pragma('journal_mode', 'WAL')
16
14
self.db_cnx.pragma('wal_autocheckpoint', '0')
-2
feeds/rapidfire.py
···
11
11
FEED_URI = 'at://did:plc:4nsduwlpivpuur4mqkbfvm6a/app.bsky.feed.generator/rapidfire'
12
12
13
13
def __init__(self):
14
14
-
super().__init__()
15
15
-
16
14
self.db_cnx = apsw.Connection('db/rapidfire.db')
17
15
self.db_cnx.pragma('journal_mode', 'WAL')
18
16
self.db_cnx.pragma('wal_autocheckpoint', '0')