diff --git a/prosopopee/prosopopee.py b/prosopopee/prosopopee.py index dcca17e..285eda8 100644 --- a/prosopopee/prosopopee.py +++ b/prosopopee/prosopopee.py @@ -47,7 +47,15 @@ def loglevel(string): help="Configure the logging level", ) subparser = parser.add_subparsers(dest="cmd") -subparser.add_parser("build", help="Generate static site") +parser_build = subparser.add_parser("build", help="Generate static site") +parser_build.add_argument( + "-j", + "--jobs", + default=None, + type=int, + help="Specifies number of jobs (thumbnail generations) to run simultaneously. Default: number " + "of threads available on the system", +) subparser.add_parser("test", help="Verify all your yaml data") subparser.add_parser("preview", help="Start preview webserver on port 9000") subparser.add_parser("deploy", help="Deploy your website") @@ -922,7 +930,12 @@ def main(): logger.info("Success: HTML file building without error") sys.exit(0) - with Pool() as pool: + # If prosopopee is started without any argument, 'build' is assumed but the jobs parameter + # is not part of the namespace, so set its default to None (or 'number of available CPU + # treads') + jobs = args.jobs if args.cmd else None + + with Pool(jobs) as pool: # Pool splits the iterable into pre-defined chunks which are then assigned to processes. # There is no other scheduling in play after that. This is an issue when chunks are # outrageously unbalanced in terms of CPU time which happens when most galleries are