Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions airflow/providers/google/cloud/hooks/cloud_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import uuid
from pathlib import Path
from subprocess import PIPE, Popen
from tempfile import gettempdir
from typing import Any, Dict, List, Optional, Sequence, Union
from urllib.parse import quote_plus

Expand Down Expand Up @@ -838,12 +839,12 @@ def _generate_unique_path() -> str:
can be close to 60 characters and there is a limitation in
length of socket path to around 100 characters in total.
We append project/location/instance to it later and postgres
appends its own prefix, so we chose a shorter "/tmp/[8 random characters]"
appends its own prefix, so we chose a shorter "${tempdir()}[8 random characters]"
"""
random.seed()
while True:
candidate = "/tmp/" + ''.join(
random.choice(string.ascii_lowercase + string.digits) for _ in range(8)
candidate = os.path.join(
gettempdir(), ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(8))
)
if not os.path.exists(candidate):
return candidate
Expand Down