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

Add flag to warn if misusing options object in multithreading scenario. #186

Open
BioTurboNick opened this issue Jun 16, 2022 · 1 comment

Comments

@BioTurboNick
Copy link

BioTurboNick commented Jun 16, 2022

Burned myself with this one with Threads.@spawn multithreading.

The Opt object is not thread-safe, and reusing it leads to problems.

I'd argue this is enough of a footgun that possibly NLopt.jl could try to detect if the same Opt object is being used simultaneously by multiple threads.

Could a flag be added to struct Opt that is set to true when accepted by optimize and false just before returning? And if the flag is already true, emit a warning or error? I suppose you'd also need a try/catch/finally to ensure it's reset to false even if there's an internal exception or interrupt.

(Accidentally posted in an unrelated issue).

@odow
Copy link
Member

odow commented Jan 25, 2023

Here's a similar issue with a example using pmap #146

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