How to set timeout limit in tortoise ORM

85 views Asked by At

I am using fastapi+tortoise. How to set total timeout (connection + execution query) limit? Tried via connection uri

DATABASE_CONFIG = {
    'connections': {
        'myconnection': f"mysql://{environ.get('DB_USERNAME', 'root')}:{environ.get('DB_PASSWORD', '')}@....com:3306/mydb?connect_timeout=1"
    }

and

DATABASE_CONFIG = {
    'connections': {
        'myconnection': {
            'engine': 'tortoise.backends.mysql',
            'credentials': {
                'host': environ.get('DB_HOST', 'mysql'),
                'port': environ.get('DB_PORT', '3306'),
                'user': environ.get('DB_USERNAME', 'root'),
                'password': environ.get('DB_PASSWORD', ''),
                'database': environ.get('DB_NAME', 'mydb'),
            },
            'options': {
                'connect_timeout': .1,
                'timeout': .1,
                'connectTimeout': .1,
                'socketTimeout': .1,
            },
        },
    }
0

There are 0 answers