Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit 2281af0

Browse files
author
Sung Won Chung
committed
test this new action
1 parent db7d864 commit 2281af0

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

.github/workflows/formatter.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,23 @@ jobs:
1010
name: runner / ruff
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v3
13+
- name: Checkout PR head
14+
uses: actions/checkout@v3
15+
if: github.event_name == 'pull_request'
16+
with:
17+
repository: ${{ github.event.pull_request.head.repo.full_name }}
18+
ref: ${{ github.event.pull_request.head.ref }}
19+
20+
- name: Checkout Repo
21+
uses: actions/checkout@v3
22+
if: github.event_name == 'workflow_dispatch'
23+
1424
- name: Check files using the ruff formatter
1525
uses: chartboost/ruff-action@v1
1626
id: ruff_formatter
1727
with:
1828
args: format
29+
1930
- name: Auto commit ruff formatting
2031
uses: stefanzweifel/git-auto-commit-action@v5
2132
with:

data_diff/databases/mysql.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, ClassVar, Dict, Type
1+
from typing import Any, ClassVar, Dict, Type, Union
22

33
import attrs
44

@@ -20,6 +20,7 @@
2020
import_helper,
2121
ConnectError,
2222
BaseDialect,
23+
ThreadLocalInterpreter,
2324
)
2425
from data_diff.databases.base import (
2526
MD5_HEXDIGITS,
@@ -148,3 +149,14 @@ def create_connection(self):
148149
elif e.errno == mysql.errorcode.ER_BAD_DB_ERROR:
149150
raise ConnectError("Database does not exist") from e
150151
raise ConnectError(*e.args) from e
152+
153+
def _query_in_worker(self, sql_code: Union[str, ThreadLocalInterpreter]):
154+
"This method runs in a worker thread"
155+
if self._init_error:
156+
raise self._init_error
157+
if not self.thread_local.conn.is_connected():
158+
try:
159+
self.thread_local.conn.ping(reconnect=True, attempts=3, delay=5)
160+
except Exception as e:
161+
raise ConnectError(*e.args) from e
162+
return self._query_conn(self.thread_local.conn, sql_code)

0 commit comments

Comments
 (0)