| skipped 21 lines |
22 | 22 | | def handle(self): |
23 | 23 | | try: |
24 | 24 | | print('[+] Connection from '+ self.client_address[0]) |
25 | | - | p = multiprocessing.Pool(5) |
| 25 | + | self.pool = multiprocessing.Pool(5) |
26 | 26 | | for output in p.imap_unordered(self.search, iter(str(self.rfile.readline), '\n')): |
27 | 27 | | if not output[0]: |
28 | 28 | | #error'd out. print the results, but don't send them on? |
| skipped 5 lines |
34 | 34 | | else: |
35 | 35 | | print('[-] No results for: {}'.format(' '.join(term))) |
36 | 36 | | |
| 37 | + | self.pool.close() |
| 38 | + | self.pool.join() |
37 | 39 | | print('[$] Closing connection from {}\n'.format(self.client_address[0])) |
38 | 40 | | except Exception as e: |
39 | | - | self.wfile.write('{{"SEARCH":"ERROR", "RESULTS":"{}"}}'.format(e).decode()) |
| 41 | + | self.pool.terminate() |
| 42 | + | self.wfile.write('{{"SEARCH":"ERROR", "RESULTS":"{}"}}'.format(e).encode()) |
40 | 43 | | print("[-] Exception Caught: {}".format(e)) |
| 44 | + | self.pool.join() |
41 | 45 | | |
42 | 46 | | def search(data): |
43 | 47 | | try: |
| skipped 47 lines |