summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2021-05-25 07:29:57 -0400
committerAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2021-05-25 07:29:57 -0400
commit2f1fbc223a8ecef5bc1a30112a847b3181090952 (patch)
tree5423e68c91b0244f7ccf0d1cbcd47402a6c6c44f
parent41bc2a0340d4f99c50d0383e4bb3265840f6e68f (diff)
downloadcgit-syntax-highlighting-2f1fbc223a8ecef5bc1a30112a847b3181090952.tar.xz
cgit-syntax-highlighting-2f1fbc223a8ecef5bc1a30112a847b3181090952.zip
don't fork if workers=1
-rwxr-xr-xsyntax-highlighting-server.py13
1 files 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()