Skip to content
Open
Show file tree
Hide file tree
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
14 changes: 12 additions & 2 deletions mypy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,20 @@ def main(
list([res]) # noqa: C410


class BuildResultThunk:
# We pass this around so that we avoid freeing memory, which is slow
def __init__(self, build_result: build.BuildResult | None) -> None:
self._result = build_result


def run_build(
sources: list[BuildSource],
options: Options,
fscache: FileSystemCache,
t0: float,
stdout: TextIO,
stderr: TextIO,
) -> tuple[build.BuildResult | None, list[str], bool]:
) -> tuple[BuildResultThunk | None, list[str], bool]:
formatter = util.FancyFormatter(
stdout, stderr, options.hide_error_codes, hide_success=bool(options.output)
)
Expand Down Expand Up @@ -227,8 +233,12 @@ def flush_errors(filename: str | None, new_messages: list[str], serious: bool) -
blockers = True
if not e.use_stdout:
serious = True

if res:
res.manager.metastore.close()

maybe_write_junit_xml(time.time() - t0, serious, messages, messages_by_file, options)
return res, messages, blockers
return BuildResultThunk(res), messages, blockers


def show_messages(
Expand Down
10 changes: 9 additions & 1 deletion mypy/metastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@ def connect_db(db_file: str, sync_off: bool = False) -> sqlite3.Connection:
# but without this flag, commits are *very* slow, especially when using HDDs,
# see https://www.sqlite.org/faq.html#q19 for details.
db.execute("PRAGMA synchronous=OFF")

mode = db.execute("PRAGMA journal_mode").fetchone()[0]
if mode.lower() != "wal":
try:
db.execute("PRAGMA journal_mode=WAL")
except sqlite3.OperationalError:
pass

db.executescript(SCHEMA)
return db

Expand All @@ -172,8 +180,8 @@ def __init__(self, cache_dir_prefix: str, sync_off: bool = False) -> None:
# We check startswith instead of equality because the version
# will have already been appended by the time the cache dir is
# passed here.
self.db = None
if cache_dir_prefix.startswith(os.devnull):
self.db = None
return

os.makedirs(cache_dir_prefix, exist_ok=True)
Expand Down
Loading