Skip to content

Commit

Permalink
make only as many threads as necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
ocket8888 committed Aug 13, 2018
1 parent 9c8594e commit 6844191
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion connmonitor/connmonitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ def run(self):
self.jsonHdr = '{"addr":"%s", "name":"%s", %%s}'
self.jsonHdr %= (self.host[0], self.hostname)

with multiprocessing.pool.ThreadPool(3) as pool:
numThreads = sum(int(bool(x)) for x in (self.conf.PING, self.conf.TRACE, self.conf.SCAN))

with multiprocessing.pool.ThreadPool(numThreads) as pool:
try:
waitables = []
if self.conf.SCAN:
Expand Down

0 comments on commit 6844191

Please sign in to comment.