Skip to content

Commit

Permalink
Changes to enable download of snapshot in validator.
Browse files Browse the repository at this point in the history
  • Loading branch information
dom96 committed Oct 4, 2024
1 parent 2178684 commit f0cb6fd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
8 changes: 1 addition & 7 deletions src/workerd/api/pyodide/pyodide.c++
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,7 @@ kj::Array<kj::String> ArtifactBundler::parsePythonScriptImports(kj::Array<kj::St
}
}

// XXX: jsg doesn't support kj::Vector return types, so this seems to be the only way to do this.
auto builder = kj::heapArrayBuilder<kj::String>(result.size());
for (auto i = 0; i < result.size(); i++) {
builder.add(kj::mv(result[i]));
}

return builder.finish();
return result.releaseAsArray();
}

jsg::Ref<PyodideMetadataReader> makePyodideMetadataReader(
Expand Down
11 changes: 3 additions & 8 deletions src/workerd/api/pyodide/pyodide.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,16 +224,11 @@ class ArtifactBundler: public jsg::Object {
kj::Maybe<MemorySnapshotResult> storedSnapshot;

ArtifactBundler(kj::Maybe<const PyodidePackageManager&> packageManager,
kj::Maybe<kj::Array<kj::byte>> existingSnapshot)
kj::Maybe<kj::Array<const kj::byte>> existingSnapshot,
bool isValidating = false)
: packageManager(packageManager),
storedSnapshot(kj::none),
existingSnapshot(kj::mv(existingSnapshot)),
isValidating(false) {};

ArtifactBundler(bool isValidating = false)
: packageManager(kj::none),
storedSnapshot(kj::none),
existingSnapshot(kj::none),
isValidating(isValidating) {};

void storeMemorySnapshot(jsg::Lock& js, MemorySnapshotResult snapshot) {
Expand Down Expand Up @@ -322,7 +317,7 @@ class ArtifactBundler: public jsg::Object {
private:
// A memory snapshot of the state of the Python interpreter after initialisation. Used to speed
// up cold starts.
kj::Maybe<kj::Array<kj::byte>> existingSnapshot;
kj::Maybe<kj::Array<const kj::byte>> existingSnapshot;
bool isValidating;
};

Expand Down

0 comments on commit f0cb6fd

Please sign in to comment.