Skip to content

PredictionEnginePool.GetPredictionEngine is not thread safe #4528

Closed
@thomasrosdahl

Description

@thomasrosdahl

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)

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions