Skip to content

Connector.py will always sleep 1 second before establishing the connection for the first time #620

Closed

Description

@luisremis

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

Activity

  1. added
    bug
    on Sep 30, 2025
  2. luisremis commented on Sep 30, 2025

    @luisremis
    ContributorAuthor
  3. gsaluja9 commented on Sep 30, 2025

    @gsaluja9
    Contributor

    Thanks. This is good. We can make the PR for the branch so that tests can be run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions