Skip to content

PredictionEnginePool.GetPredictionEngine is not thread safe #4528

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

Closed
thomasrosdahl opened this issue Dec 6, 2019 · 2 comments
Closed

PredictionEnginePool.GetPredictionEngine is not thread safe #4528

thomasrosdahl opened this issue Dec 6, 2019 · 2 comments
Assignees

Comments

@thomasrosdahl
Copy link

System information

  • OS version/distro: Windows 10
  • .NET Version (eg., dotnet --info): Azure Functions Runtime 2.7.1948

Issue

  • What did you do?
    Invoked PredictionEnginePool.Predict("MyModelName", example) from multiple threads.

  • What happened?
    System.ArgumentException: 'An item with the same key has already been added. Key: MyModelName'

  • What did you expect?
    Method is thread safe so that multiple named pools cannot be created simultaneously.

Source code / logs

at System.ThrowHelper.ThrowAddingDuplicateWithKeyArgumentException[T](T key)
at System.Collections.Generic.Dictionary2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at Microsoft.Extensions.ML.PredictionEnginePool2.GetPredictionEngine(String modelName)
at Microsoft.Extensions.ML.PredictionEnginePoolExtensions.Predict[TData,TPrediction](PredictionEnginePool`2 predictionEnginePool, String modelName, TData example)

@gvashishtha
Copy link
Contributor

@frank-dong-ms

@frank-dong-ms-zz
Copy link
Contributor

Fix has been checked in.

@ghost ghost locked as resolved and limited conversation to collaborators Mar 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants