Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why use ThreadPoolExecutor with GIL in background? #36

Open
johnmclain opened this issue Jan 25, 2024 · 1 comment
Open

why use ThreadPoolExecutor with GIL in background? #36

johnmclain opened this issue Jan 25, 2024 · 1 comment

Comments

@johnmclain
Copy link

johnmclain commented Jan 25, 2024

In evaluation the code uses ThreadPoolExecutor at first and in each thread use multiprocessing package. Why not use ProcessPoolExecutor at first? Is there any consideration of optimizing performance?

@rjarun8235
Copy link

@johnmclain

The ThreadPoolExecutor is used for concurrently executing the validation task for multiple generated code samples. Now these code sample validation are further wrapped as a process via multiprocessing to contain and isolate it . This ensures there is no conflict and also as a system security measure , executing and validating unsafe code.

Now why not processpool directly?

Threads are light and scales well with resources.
using a processpool directly is slightly less secure approach to validate unsafe code

If the code is safe code , using processpool directly makes a better sense.

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

No branches or pull requests

2 participants