Graceful exit from a parfor loop

If I detect an error while processing data within a parfor loop, I would like to gracefully exit the program. Can I delete the parallel pool object using "delete" to shut down all of the workers before exiting?

Answers (1)

Matt J
Matt J about 2 hours ago
It sounds like a job for onCleanup.

1 Comment

Clay Fulcher
Clay Fulcher 12 minutes ago
Edited: Clay Fulcher 11 minutes ago
Thanks Matt. I'll give this a try. I'm not sure it will destroy all the independent workers in a parallel loop, but I'll give it a try. Do you know if simply deleting the parallel pool object will accomplish the destruction of the tasks being performed by all the independent workers in the parfor loop?

Sign in to comment.

Categories

Products

Release

R2025b

Asked:

about 13 hours ago

Edited:

about 9 hours ago

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!