def connectionMade(self):
        """
        When connection is made, create the AMP protocol instance.
        """
        self._ampProtocol.makeConnection(LocalWorkerTransport(self.transport))
        if not os.path.exists(self._logDirectory):
            os.makedirs(self._logDirectory)
        self._outLog = open(os.path.join(self._logDirectory, 'out.log'), 'wb')
        self._errLog = open(os.path.join(self._logDirectory, 'err.log'), 'wb')
        self._testLog = open(
            os.path.join(self._logDirectory, self._logFile), 'w')
        self._ampProtocol.setTestStream(self._testLog)
        logDirectory = self._logDirectory
        d = self._ampProtocol.callRemote(workercommands.Start,
                                         directory=logDirectory)
        # Ignore the potential errors, the test suite will fail properly and it
        # would just print garbage.
        d.addErrback(lambda x: None)

        When connection is made, create the AMP protocol instance.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/trial/_dist/worker.py