Skip to content
Merged
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
6 changes: 2 additions & 4 deletions .github/workflows/stdlib-introspect.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
introspect:
name: introspect ${{ matrix.os }} / py${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
timeout-minutes: 5
timeout-minutes: 1
Comment thread
shenanigansd marked this conversation as resolved.
strategy:
Comment thread
shenanigansd marked this conversation as resolved.
fail-fast: false
matrix:
Expand All @@ -50,8 +50,6 @@ jobs:
INCLUDE_DUNDERS: ${{ github.event.inputs.include_dunders || 'false' }}
INCLUDE_PRIVATE: ${{ github.event.inputs.include_private || 'false' }}
OUT: stdlib_api_${{ matrix.os }}_py${{ matrix.python-version }}.jsonl
WATCHDOG_SECONDS: "120"
TRACE_IMPORTS: "1"
run: |
flags=()
[ "$INCLUDE_DUNDERS" = "true" ] && flags+=(--include-dunders)
Expand All @@ -76,7 +74,7 @@ jobs:
needs: [introspect]
if: always() # union whatever cells succeeded, even if some cells failed
runs-on: ubuntu-latest
timeout-minutes: 5
timeout-minutes: 1
Comment thread
shenanigansd marked this conversation as resolved.
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

Expand Down
17 changes: 3 additions & 14 deletions tools/stdlib_introspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ def safe_import(name):
short_name = name.split(".")[-1]
if name in SKIP_MODULES or short_name in SKIP_MODULES:
return None
if os.environ.get("TRACE_IMPORTS"):
print(f" importing {name}", file=sys.stderr, flush=True)
print(f" importing {name}", flush=True)
try:
with _silenced():
return importlib.import_module(name)
Expand Down Expand Up @@ -208,13 +207,7 @@ def main():
parser.add_argument("--min-entities", type=int, default=5000,
help="sanity gate: exit non-zero if fewer than N records were "
"produced (a near-empty dump means the build is broken)")
parser.add_argument("--watchdog", type=int, default=int(os.environ.get("WATCHDOG_SECONDS", "0")),
help="if >0: dump all thread stacks and abort after N seconds "
"(a stdlib module that HANGS on import can't be caught by try/except)")
args = parser.parse_args()
if args.watchdog > 0:
import faulthandler
faulthandler.dump_traceback_later(args.watchdog, exit=True)

scanned, failed = 0, []
for name, module in roster(args.include_private):
Expand Down Expand Up @@ -250,13 +243,9 @@ def main():

# Gate last, after the output and summaries are written, so a broken cell still
# uploads its dump and renders a summary before the non-zero exit fails the job.
sys.stdout.flush(); sys.stderr.flush()
if len(records) < args.min_entities:
print(f"\nSANITY GATE: only {len(records)} records "
f"(< --min-entities {args.min_entities}); this build looks broken.",
file=sys.stderr, flush=True)
os._exit(1)
os._exit(0)
sys.exit(f"\nSANITY GATE: only {len(records)} records (< --min-entities "
f"{args.min_entities}); this build looks broken.")

def _stats(records, scanned, failed):
from collections import Counter
Expand Down