Skip to content

Commit aedc65c

Browse files
authored
Revert "Fixed daemon detection to determine forking behavior" (#3146)
1 parent f7c7d0a commit aedc65c

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

sqlmesh/core/constants.py

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from __future__ import annotations
22

33
import datetime
4+
import multiprocessing as mp
45
import os
5-
import sys
66
import typing as t
77
from pathlib import Path
88

@@ -32,27 +32,11 @@
3232
"""Maximum number of characters in a model definition"""
3333

3434

35-
def is_daemon_process() -> bool:
36-
"""
37-
Determines whether the current process is running as a daemon (background process).
38-
39-
This function checks if the standard output (stdout) is connected to a terminal.
40-
It does this by calling `sys.stdout.fileno()` to retrieve the file descriptor
41-
for the stdout stream and `os.isatty()` to check if this file descriptor is
42-
associated with a terminal device.
43-
44-
Returns:
45-
bool: True if the process is running as a daemon (not attached to a terminal),
46-
False if the process is running in a terminal (interactive mode).
47-
"""
48-
return not os.isatty(sys.stdout.fileno())
49-
50-
5135
# The maximum number of fork processes, used for loading projects
5236
# None means default to process pool, 1 means don't fork, :N is number of processes
5337
# Factors in the number of available CPUs even if the process is bound to a subset of them
5438
# (e.g. via taskset) to avoid oversubscribing the system and causing kill signals
55-
if hasattr(os, "fork") and not is_daemon_process():
39+
if hasattr(os, "fork") and not mp.current_process().daemon:
5640
try:
5741
MAX_FORK_WORKERS: t.Optional[int] = int(os.getenv("MAX_FORK_WORKERS")) # type: ignore
5842
except TypeError:
@@ -97,6 +81,7 @@ def is_daemon_process() -> bool:
9781
SQLMESH_BUILTIN = "__sqlmesh__builtin__"
9882
SQLMESH_METADATA = "__sqlmesh__metadata__"
9983

84+
10085
BUILTIN = "builtin"
10186
AIRFLOW = "airflow"
10287
DBT = "dbt"

0 commit comments

Comments
 (0)