Parallel file matching, Python

后端 未结 4 1166
渐次进展
渐次进展 2020-12-15 02:02

I am trying to improve on a script which scans files for malicious code. We have a list of regex patterns in a file, one pattern on each line. These regex are for grep as

4条回答
  •  温柔的废话
    2020-12-15 02:38

    If you are willing to upgrade to version 3.2 or better, you can take advantage of the concurrent.futures.ProcessPoolExecutor. I think it will improve performance over the popen method you attempted because it will pre-create a pool of processes where your popen method creates a new process every time. You could write your own code to do the same thing for an earlier version if you can't move to 3.2 for some reason.

提交回复
热议问题