Skip to content

Commit

Permalink
fix(trino): add delay time to avoid Trino issue
Browse files Browse the repository at this point in the history
  • Loading branch information
grieve54706 committed Nov 14, 2024
1 parent 82a2e7b commit 5b1ac8c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modules/trino/testcontainers/trino/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import re
import time

from testcontainers.core.config import testcontainers_config as c
from testcontainers.core.generic import DbContainer
Expand All @@ -24,12 +25,14 @@ def __init__(
image="trinodb/trino:latest",
user: str = "test",
port: int = 8080,
delay: int = 5,
**kwargs,
):
super().__init__(image=image, **kwargs)
self.user = user
self.port = port
self.with_exposed_ports(self.port)
self.delay = delay

@wait_container_is_ready()
def _connect(self) -> None:
Expand All @@ -39,6 +42,8 @@ def _connect(self) -> None:
c.max_tries,
c.sleep_time,
)
# To avoid `TrinoQueryError(type=INTERNAL_ERROR, name=GENERIC_INTERNAL_ERROR, message="nodes is empty")`
time.sleep(self.delay)
conn = connect(
host=self.get_container_host_ip(),
port=self.get_exposed_port(self.port),
Expand Down

0 comments on commit 5b1ac8c

Please sign in to comment.