Skip to content

Commit

Permalink
add multiprocessing pool #91
Browse files Browse the repository at this point in the history
  • Loading branch information
dantheta committed Mar 20, 2021
1 parent c8f0455 commit 7a822da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions importers/nominet/import-nominet.example.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ path=

[paths]
download=

[worker]
threads=
7 changes: 6 additions & 1 deletion importers/nominet/import-nominet.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import datetime
import subprocess
import configparser
import multiprocessing

import psycopg2
import paramiko
Expand Down Expand Up @@ -153,9 +154,13 @@ def main():

unpack(cfg, filename)

pool = multiprocessing.Pool(cfg.getint('worker', 'threads'))

conn = connect_db(cfg)

for name in resolve_iter(compare(cfg, filename)):
for name in pool.imap_unordered(resolve, compare(cfg, filename), chunksize=16):
if name is None:
continue
logging.info("Got: %s", name)
dbstore(conn, name)
if args.debug:
Expand Down

0 comments on commit 7a822da

Please sign in to comment.