Skip to content

Conversation

@zetter-rpf
Copy link
Contributor

@zetter-rpf zetter-rpf commented Jan 13, 2026

closes RaspberryPiFoundation/digital-editor-issues/issues/878

In [1] we changed pyodide to keep the current state rather than reloading on each run in order to speed up loading of large packages.

A consequence of this is that local files are also not reloaded. This means that class variables and other data can persist between runs.

To fix this, make sure we clear all local modules as well as global varibles. We need to import the sys module to do this (which will then be unloaded as a global variable in the same function).

An alternative to this approach that I considered is to create new instances of pyodide, but keep the state site-packages directory between runs which may be possible and would better mirror how python runs locally. I couldn't get this to work as the FS interface has limited options and,I think would have to manually copy files to a local variable and back again to do this.

[1] #1113

@zetter-rpf zetter-rpf temporarily deployed to previews/1287/merge January 13, 2026 10:19 — with GitHub Actions Inactive
Closes RaspberryPiFoundation/digital-editor-issues#878

In [1] we changed pyodide to keep the current state rather than reloading on each run in order to speed up loading of large packages.

A consquence of this is that local files are also not reloaded. This means that class variables and other data can persist between runs.

To fix this, make sure we clear all local modules as well as global varibles. We need to import the sys module to do this (which will then be unloaded as a global variable in the same function).

An alternative to this approach that I considered is to create new instances of pyodide, but keep the state site-packages directory between runs which may be possible and would better mirror how python runs locally. I couldn't get this to work as the FS interface has limited options and,I think would have to manually copy files to a local variable and back again to do this.

[1] #1113
@zetter-rpf zetter-rpf changed the title Clear loaded modules Clear loaded modules to remove state between runs Jan 13, 2026
@zetter-rpf zetter-rpf force-pushed the fix-local-imported-file-cache branch from 4ba09eb to b7a8b89 Compare January 13, 2026 10:35
@zetter-rpf zetter-rpf temporarily deployed to previews/1287/merge January 13, 2026 10:36 — with GitHub Actions Inactive
@zetter-rpf zetter-rpf marked this pull request as ready for review January 13, 2026 10:37
@zetter-rpf zetter-rpf temporarily deployed to previews/1287/merge January 15, 2026 10:27 — with GitHub Actions Inactive
@zetter-rpf zetter-rpf force-pushed the fix-local-imported-file-cache branch from 48a3050 to 18ec4e5 Compare January 15, 2026 16:18
@zetter-rpf zetter-rpf temporarily deployed to previews/1287/merge January 15, 2026 16:18 — with GitHub Actions Inactive
Copy link
Contributor

@loiswells97 loiswells97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, will be good to get this fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants