-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Connector.py will always sleep 1 second (because the "reconnection" mechanism will be triggered) before running the first query.
This is because self.conn = None when we get here for the first time: https://github.com/aperture-data/aperturedb-python/blob/develop/aperturedb/Connector.py#L429
This has been causing a significant slowdown on aperturedb test suite, which relies on the python sdk, because tests that would take a few miliseconds, are all taking 1 extra second every time a connector is created:
https://github.com/aperture-data/athena/actions/runs/18048645146/job/51371146711#step:6:41
The extra 1 second slowdown on the first query is because of this sleep: https://github.com/aperture-data/aperturedb-python/blob/develop/aperturedb/Connector.py#L479 | https://github.com/aperture-data/aperturedb-python/blob/develop/aperturedb/Connector.py#L64
The slowdown is also observed on customer deployments when running the first query, and is particularly observed when the watchdog application, which establishes new connections to check connectivity, always does a (fake) "reconnection":
Checking aperturedb.customer.com...
WARNING:aperturedb.Connector:Connection broken. Reconnecting attempt [1/3] .. PID = 27
1214.6167755126953 ms
The solution could be as simple as:
@@ -401,6 +440,12 @@ class Connector(object):
stack_info=True)
def _query(self, query, blob_array = [], try_resume=True):
+
+ if self.conn is None:
+ self.connect()
but further tests would be needed to make sure nothing else breaks as a consequence