Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timeout-decorator doesn't work with mysql-connection-python CMySQLConnection #86

Open
ToanLyHoa opened this issue Jul 11, 2024 · 1 comment

Comments

@ToanLyHoa
Copy link

# mysql.connector version 9.0.0

@timeout_decorator.timeout(timeout=5, 
                          timeout_exception=ConnectionError) 
def connect_database(self) -> None:
    
      connection = mysql.connector.connect(
          host=self.host,
          port=self.port,
          user=self.user,
          password=self.password,
          database=self.database,
          # default
          use_pure = False,
      )
    

The code above doesn't work, maybe in CMySQLConnection write in C they set signal.alarm(0) when we don't pass connection_timeout in this connect function..

@ToanLyHoa
Copy link
Author

ToanLyHoa commented Jul 11, 2024

After changing use_pure = True, timeout is working because socket.settimeout(None) will not effect to SIGALRM. This is not an issue, this is a notification for anyone who encounters this issue like me.

# mysql.connector version 9.0.0

@timeout_decorator.timeout(timeout=5, 
                          timeout_exception=ConnectionError) 
def connect_database(self) -> None:
    
      connection = mysql.connector.connect(
          host=self.host,
          port=self.port,
          user=self.user,
          password=self.password,
          database=self.database,
          # default
          use_pure = True,
      )
    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant