Skip to content

Commit 3647224

Browse files
committed
fix: replace file walk with targeted pyarrow imports in warmup
Signed-off-by: danbugs <danilochiarlone@gmail.com>
1 parent a89bf59 commit 3647224

1 file changed

Lines changed: 2 additions & 16 deletions

File tree

examples/python-agent-driver/hl_pydriver.c

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -265,28 +265,14 @@ static void py_initialize_once(void)
265265
* (without initrd re-mapping) the .py files are zeroed pages. */
266266
PyRun_SimpleString(
267267
"try:\n"
268+
" import pyarrow.pandas_compat\n"
269+
" import pyarrow.vendored.version\n"
268270
" import pandas as _pd\n"
269271
" _pd.DataFrame({'_': ['x']})\n"
270272
" del _pd\n"
271273
"except Exception:\n"
272274
" pass\n");
273275

274-
/* Page in all .py sources so they survive snapshot restore.
275-
* The snapshot captures only pages faulted during warmup; any
276-
* .py file not yet read would appear as null bytes after restore
277-
* (since we skip initrd re-mapping to avoid overlap). */
278-
PyRun_SimpleString(
279-
"import os as _os\n"
280-
"for _r, _d, _ff in _os.walk('/usr/local/lib/python3.12'):\n"
281-
" for _fn in _ff:\n"
282-
" if _fn.endswith('.py'):\n"
283-
" try:\n"
284-
" with open(_os.path.join(_r, _fn), 'rb') as _fh:\n"
285-
" _fh.read()\n"
286-
" except Exception:\n"
287-
" pass\n"
288-
"del _os\n");
289-
290276
/* Monkey-patch zipfile.ZipInfo.__init__ to clamp pre-1980 timestamps.
291277
* Unikraft's ramfs reports epoch-0 (1970) for file mtimes; Python's
292278
* zipfile rejects timestamps before 1980, breaking openpyxl's XLSX

0 commit comments

Comments
 (0)