Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3a916ac

Browse files
committedNov 14, 2024·
fixup! [IMP] snippets: move all work from parent to mp workers
1 parent fe9b2c8 commit 3a916ac

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed
 

‎src/util/snippets.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -248,17 +248,22 @@ def _dumps(self, node):
248248

249249

250250
class Convertor:
251-
def __init__(self, converters, callback, dbname, update_query):
251+
def __init__(self, converters, callback, dbname=None, update_query=None):
252252
self.converters = converters
253253
self.callback = callback
254254
self.dbname = dbname
255255
self.update_query = update_query
256256

257257
def __call__(self, query):
258+
# backwards compatibility
259+
if not (self.dbname and self.update_query and isinstance(query, str)):
260+
return self._convert_row(query)
261+
# called with a query to fetch a number of rows
258262
with db_connect(self.dbname).cursor() as cr:
259263
cr.execute(query)
260264
for changes in filter(None, map(self._convert_row, cr.fetchall())):
261265
cr.execute(self.update_query, changes)
266+
return None
262267

263268
def _convert_row(self, row):
264269
converters = self.converters

0 commit comments

Comments
 (0)
Please sign in to comment.