From 2f1fbc223a8ecef5bc1a30112a847b3181090952 Mon Sep 17 00:00:00 2001 From: "Alex Xu (Hello71)" Date: Tue, 25 May 2021 07:29:57 -0400 Subject: don't fork if workers=1 --- syntax-highlighting-server.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/syntax-highlighting-server.py b/syntax-highlighting-server.py index d650664..6a13393 100755 --- a/syntax-highlighting-server.py +++ b/syntax-highlighting-server.py @@ -74,11 +74,14 @@ def main(): else: workers = args.workers - with ProcessPoolExecutor(max_workers=workers) as pool: - gc.collect() - gc.freeze() - pool.map(noop, [None] * workers) - run(args, pool) + if workers == 1: + run(args) + else: + with ProcessPoolExecutor(max_workers=workers) as pool: + gc.collect() + gc.freeze() + pool.map(noop, [None] * workers) + run(args, pool) if __name__ == '__main__': main() -- cgit v1.2.3-70-g09d2