From what I can tell jaydebeapi contains no built-in timeout capability, so then I turned to https://pypi.org/project/timeout-decorator/.My goal is to have a default timeout of, say, 10 seconds, which can be overridden by the caller.
I'm writing a database connectivity module to be used by other modules and leveraging the jaydebeapi module.
From what I can tell jaydebeapi contains no built-in timeout capability, sothen I turned to https://pypi.org/project/timeout-decorator/.
My goal is to have a default timeout of, say, 10 seconds, which can be overridden by the caller.
import jaydebeapi
from timeout_decorator import timeout
class Database:
database_connection = None
database_name, user_name, password, host, port = stuff
timeout = None
def __init__(self, timeout=10):
self.timeout = timeout
@timeout(self.timeout)
def get_connection(self):
if not self.database_connection:
self.database_connection = jaydebeapi.connect(some_args)
return self.database_connection
The trouble occurs on line 12 with:
NameError: name 'self' is not defined
I'm writing a database connectivity module to be used by other modules and leveraging the jaydebeapi module.
From what I can tell jaydebeapi contains no built-in timeout capability, so then I turned to https://pypi.org/project/timeout-decorator/.
My goal is to have a default timeout of, say, 10 seconds, which can be overridden by the caller.
import jaydebeapi
from timeout_decorator import timeout
class Database:
database_connection = None
database_name, user_name, password, host, port = stuff
timeout = None
def __init__(self, timeout=10):
self.timeout = timeout
@timeout(self.timeout)
def get_connection(self):
if not self.database_connection:
self.database_connection = jaydebeapi.connect(some_args)
return self.database_connection
The trouble occurs on line 12 with:
NameError: name 'self' is not defined
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 300 |
Nodes: | 16 (2 / 14) |
Uptime: | 58:54:04 |
Calls: | 6,712 |
Files: | 12,243 |
Messages: | 5,355,639 |