INNER CODE UNIT · Python

connect

baileydanseglio/thetadata-python · thetadata/client.py:339

    def connect(self):
        """Initiate a connection with the Theta Terminal. Requests can only be made inside this
            generator aka the `with client.connect()` block.

        :raises ConnectionRefusedError: If the connection failed.
        :raises TimeoutError: If the timeout is set and has been reached.
        """

        try:
            for i in range(15):
                try:
                    self._server = socket.socket()
                    self._server.connect((self.host, self.port))
                    self._server.settimeout(1)
                    break
                except ConnectionError:
                    if i == 14:
                        raise ConnectionError('Unable to connect to the local Theta Terminal process.'

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…