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