add wait
This commit is contained in:
parent
f507efce60
commit
d3a03e1cb3
@ -3,7 +3,7 @@ from requests.auth import HTTPBasicAuth
|
|||||||
from getpass import getpass
|
from getpass import getpass
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
from concurrent import futures
|
from concurrent import futures
|
||||||
from concurrent.futures import as_completed, wait
|
from concurrent.futures import as_completed, wait, ALL_COMPLETED
|
||||||
|
|
||||||
import argparse, logging, threading
|
import argparse, logging, threading
|
||||||
from lib.WPImport import WPimport
|
from lib.WPImport import WPimport
|
||||||
@ -221,9 +221,10 @@ if __name__ == '__main__':
|
|||||||
importWp.setUrl(i)
|
importWp.setUrl(i)
|
||||||
importWp.fromFile(files=args.file.split(","))
|
importWp.fromFile(files=args.file.split(","))
|
||||||
if len(args.directory) > 0:
|
if len(args.directory) > 0:
|
||||||
remove(args, basic, logger, ssl_wordpress)
|
|
||||||
try:
|
try:
|
||||||
with futures.ThreadPoolExecutor(max_workers=int(args.parallel)) as ex:
|
with futures.ThreadPoolExecutor(max_workers=int(args.parallel)) as ex:
|
||||||
|
wait_for = [ ex.submit(remove, i, args.parallel, args, basic, logger, ssl_wordpress) for i in range(0, int(args.parallel)) ]
|
||||||
|
wait(wait_for, return_when=ALL_COMPLETED)
|
||||||
wait_for = [
|
wait_for = [
|
||||||
ex.submit(importDirectory, i, int(args.parallel), args.directory, logger, args.parser, args.wordpress, basic, args.serial, ssl_wordpress)
|
ex.submit(importDirectory, i, int(args.parallel), args.directory, logger, args.parser, args.wordpress, basic, args.serial, ssl_wordpress)
|
||||||
for i in range(0, int(args.parallel))
|
for i in range(0, int(args.parallel))
|
||||||
@ -231,13 +232,16 @@ if __name__ == '__main__':
|
|||||||
except Exception as err:
|
except Exception as err:
|
||||||
logger.error("Threading error : {0}".format(err))
|
logger.error("Threading error : {0}".format(err))
|
||||||
if len(args.canalblog) > 0:
|
if len(args.canalblog) > 0:
|
||||||
remove(args, basic, logger, ssl_wordpress)
|
|
||||||
try:
|
try:
|
||||||
with futures.ThreadPoolExecutor(max_workers=int(args.parallel)) as ex:
|
with futures.ThreadPoolExecutor(max_workers=int(args.parallel)) as ex:
|
||||||
|
wait_for = [ ex.submit(remove, i, args.parallel, args, basic, logger, ssl_wordpress) for i in range(0, int(args.parallel)) ]
|
||||||
|
wait(wait_for, return_when=ALL_COMPLETED)
|
||||||
wait_for = [
|
wait_for = [
|
||||||
ex.submit(importUrl, i, int(args.parallel), args.canalblog, logger, args.parser, args.wordpress, basic, args.serial, ssl_wordpress, ssl_canalblog)
|
ex.submit(importUrl, i, int(args.parallel), args.canalblog, logger, args.parser, args.wordpress, basic, args.serial, ssl_wordpress, ssl_canalblog)
|
||||||
for i in range(0, int(args.parallel))
|
for i in range(0, int(args.parallel))
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
logger.error("Threading error : {0}".format(err))
|
logger.error("Threading error : {0}".format(err))
|
||||||
exit(0)
|
exit(0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user