Skip to content

Only delete zipapps cache on the main process#33

Open
Joshix-1 wants to merge 3 commits intoClericPy:masterfrom
Joshix-1:multiprocessing-fix
Open

Only delete zipapps cache on the main process#33
Joshix-1 wants to merge 3 commits intoClericPy:masterfrom
Joshix-1:multiprocessing-fix

Conversation

@Joshix-1
Copy link
Copy Markdown

With multiprocessing only the main process should delete the cache. Otherwise exceptions get thrown on exit. Silently ignoring exceptions would not work, as then when a single child dies the files would be gone.

With multiprocessing only the main process should delete the cache. Otherwise exceptions get thrown on exit.
Silently ignoring exceptions would not work, as then when a single child dies the files would be gone.
@ClericPy
Copy link
Copy Markdown
Owner

ClericPy commented Apr 1, 2026

how to test this change?

@Joshix-1
Copy link
Copy Markdown
Author

Joshix-1 commented Apr 1, 2026

create a zipapp with code like the following:

import os
os.fork()
print(os.getpid())

@ClericPy
Copy link
Copy Markdown
Owner

ClericPy commented Apr 1, 2026

https://github.com/ClericPy/zipapps/blob/master/test_utils.py

What I mean is that there is a test case that can run successfully on different operating systems to verify that changes are valid and scenarios are explained

Which is to prove the value of the change, and regression testing to avoid side effects.

@ClericPy
Copy link
Copy Markdown
Owner

ClericPy commented Apr 1, 2026

By the way, zipapps are actually not recommended to remove themselves after taking over the run. It's not as safe as an external program, which is not a very regular feature in itself.

@Joshix-1
Copy link
Copy Markdown
Author

Joshix-1 commented Apr 1, 2026

What I mean is that there is a test case that can run successfully on different operating systems to verify that changes are valid and scenarios are explained

I'll try to write a test

By the way, zipapps are actually not recommended to remove themselves after taking over the run. It's not as safe as an external program, which is not a very regular feature in itself.

This is about removing the files from the cache. E.g. the .so files of dependencies that get extracted.

@Joshix-1 Joshix-1 force-pushed the multiprocessing-fix branch from 1d8f91a to 2a61ba9 Compare April 1, 2026 16:49
@Joshix-1
Copy link
Copy Markdown
Author

Joshix-1 commented Apr 1, 2026

Added a test. Sadly I don't know how to test on windows, as os.fork is not available there.

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.

2 participants