Skip to content

Commit 4560351

Browse files
committed
Add the missing bits for episode 580
1 parent 06f33de commit 4560351

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

sample_code/ep580/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ bash t.sh
4545

4646
git -C ../../uwsgi diff -- core/
4747
git -C ../../uwsgi diff -- core/ | git apply
48+
cd ../../
4849

4950
./venv/bin/pip uninstall pyuwsgi
50-
./venv/bin/pip install ./pyuwsgi-wheels/uwsgi
51+
./venv/bin/pip install ./pyuwsgi-wheels/uwsgi/
5152

5253
nano pyuwsgi-wheels/uwsgi/plugins/pyuwsgi/pyuwsgi.c
5354
```

sample_code/ep580/rev01/bisect-uwsgi.py

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,48 @@
11
from __future__ import annotations
22
import contextlib
33
import os.path
4-
# import shlex
4+
import shlex
55
import subprocess
66
import urllib.request
77
import sys
88
import time
9-
from typing import Generator
10-
# from typing import IO
119
import psutil
1210

11+
from typing import Generator, IO
12+
1313

1414
rev = subprocess.check_output(('git', 'rev-parse', 'HEAD'), text=True).strip()
1515

1616
prefix = os.path.abspath('../prefix')
1717
venv = os.path.abspath('../venv')
1818
logs = os.path.abspath('../logs')
1919
uwsgi_src = os.path.abspath('../pyuwsgi-wheels/uwsgi')
20+
os.makedirs(logs, exist_ok=True)
2021

2122

22-
def tee() -> None:
23-
...
23+
def tee(s: str, *files: IO[str]) -> None:
24+
for f in files:
25+
print(s, file=f, flush=True)
2426

2527

26-
def _cmd_q() -> None:
27-
...
28+
def _cmd_q(
29+
*cmd: str,
30+
env: dict[str, str] | None = None,
31+
cwd: str | None = None,
32+
exit: int = 125,
33+
) -> None:
34+
with open(os.path.join(logs, rev), 'a+') as logfile:
35+
tee(f'+ {shlex.join(cmd)}', logfile, sys.stderr)
36+
ret = subprocess.call(
37+
cmd,
38+
env=env,
39+
cwd=cwd,
40+
stdout=logfile,
41+
stderr=logfile,
42+
)
43+
if ret:
44+
tee(f'=> failed with {ret}', logfile, sys.stderr)
45+
raise SystemExit(exit)
2846

2947

3048
def _build_cpython() -> None:

0 commit comments

Comments
 (0)