Skip to content
File

Blob: src/workerd/server/tests/python/dont-snapshot-pyodide/worker.py

python23 lines
1"""
2To trigger the bug we need to do two things:
31. import `pyodide` at top level
42. ensure that there is some package requirement in wd-test
53. make test() async
6
7Importing numpy isn't really necessary but we need to include it as a requirement in the wd-test
8file so that we consider making a package snapshot. In the buggy code, importing pyodide at top
9level then makes the package snapshot import pyodide while making the snapshot. Importing pyodide
10before calling finalizeBootstrap messes up the runtime state and causes various weird and malign
11symptoms.
12"""
13 
14import numpy
15 
16import pyodide
17 
18 
19async def test():
20 # Mention imports so that ruff won't remove them
21 pyodide # noqa: B018
22 numpy # noqa: B018