Changeset f6d2721 in mod_gnutls


Ignore:
Timestamp:
Dec 6, 2019, 11:28:23 AM (12 months ago)
Author:
Fiona Klute <fiona.klute@…>
Branches:
master, proxy-ticket
Children:
d762813
Parents:
0560bb9
Message:

HTTPSubprocessConnection: Run filter in a thread instead of process

This is a minor performance improvement in this use case (I
measured). Filter and HTTP processing can't really run in parallel,
because the latter needs the output of the former.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/mgstest/http.py

    r0560bb9 rf6d2721  
    2121
    2222from http.client import HTTPConnection
    23 from multiprocessing import Process
     23from threading import Thread
    2424
    2525class HTTPSubprocessConnection(HTTPConnection):
     
    5050        # and the socket back to the HTTP connection (write-only).
    5151        self._output_filter = output_filter
    52         # output filter process
    53         self._fproc = None
     52        # output filter thread
     53        self._fthread = None
    5454
    5555    def connect(self):
     
    6363                                           stdin=s_remote, close_fds=True,
    6464                                           bufsize=0)
    65             self._fproc = Process(target=self._output_filter,
    66                                   args=(self._sproc.stdout, s_remote))
    67             self._fproc.start()
     65            self._fthread = Thread(target=self._output_filter,
     66                                   args=(self._sproc.stdout, s_remote))
     67            self._fthread.start()
    6868        else:
    6969            self._sproc = subprocess.Popen(self.command, stdout=s_remote,
    7070                                           stdin=s_remote, close_fds=True,
    7171                                           bufsize=0)
    72         s_remote.close()
    7372        self.sock = s_local
    7473
     
    9190                    self.returncode = self._sproc.wait(self.timeout)
    9291
    93         # filter process receives HUP on pipe when the subprocess
     92        # filter thread receives HUP on pipe when the subprocess
    9493        # terminates
    95         if self._fproc:
    96             self._fproc.join()
     94        if self._fthread:
     95            self._fthread.join()
    9796
    9897        # close the connection in the super class, which also calls
Note: See TracChangeset for help on using the changeset viewer.