Skip to content

Commit

Permalink
drop testing code
Browse files Browse the repository at this point in the history
  • Loading branch information
eloyfelix committed Feb 3, 2022
1 parent 388543e commit 5fff0bc
Showing 1 changed file with 22 additions and 28 deletions.
50 changes: 22 additions & 28 deletions cbl_migrator/migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,34 +389,28 @@ def migrate(

# SQLite accepts concurrent read but not write
processes = 1 if d_eng.name == "sqlite" else self.n_cores
o_eng.dispose()
d_eng.dispose()
if processes == 1:
for table in tables:
fill_table(self.o_eng_conn, self.d_eng_conn, table, chunk_size)
else:
with cf.ProcessPoolExecutor(max_workers=processes) as exe:
futures = {
exe.submit(
fill_table,
self.o_eng_conn,
self.d_eng_conn,
table,
chunk_size,
): table
for table in tables
}

for future in cf.as_completed(futures):
table = futures[future]
try:
res = future.result()
if not res:
logger.error(
f"Something went wrong when copying table: {table}"
)
except Exception as e:
logger.error(f"Table {table} worker died: ", e)
with cf.ProcessPoolExecutor(max_workers=processes) as exe:
futures = {
exe.submit(
fill_table,
self.o_eng_conn,
self.d_eng_conn,
table,
chunk_size,
): table
for table in tables
}

for future in cf.as_completed(futures):
table = futures[future]
try:
res = future.result()
if not res:
logger.error(
f"Something went wrong when copying table: {table}"
)
except Exception as e:
logger.error(f"Table {table} worker died: ", e)

# check row counts for each table
if not copy_data:
Expand Down

0 comments on commit 5fff0bc

Please sign in to comment.