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

Can I start several instances of FsiEvaluationSession.Create(...) concurrently ? #798

Closed
goswinr opened this issue Sep 3, 2017 · 3 comments

Comments

@goswinr
Copy link
Contributor

goswinr commented Sep 3, 2017

I sometimes get exceptions like this below when I create several instances of FsiEvaluationSession at almost the same time. I do not run evaluations on them yet. This does not happen always and the affected assembly is not always the same.
Is this a concurrency issue? I would like to know if it is OK to create (and run) several FSI Session concurrently?

error FS3160: Problem reading assembly 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Runtime.dll': Object reference not set to an instance of an object.
Error creating evaluation session: StopProcessingExn None
   at Microsoft.FSharp.Compiler.Interactive.Shell.-ctor@2576-143.Invoke(String message) in C:\projects\fsharp-compiler-service\src\fsharp\fsi\fsi.fs:line 2576
   at Microsoft.FSharp.Compiler.Interactive.Shell.FsiEvaluationSession..ctor(FsiEvaluationSessionHostConfig fsi, String[] argv, TextReader inReader, TextWriter , TextWriter errorWriter, Boolean fsiCollectible, Boolean msbuildEnabled) in C:\projects\fsharp-compiler-service\src\fsharp\fsi\fsi.fs:line 2422
   at Microsoft.FSharp.Compiler.Interactive.Shell.FsiEvaluationSession.Create(FsiEvaluationSessionHostConfig fsiConfig, String[] argv, TextReader inReader, TextWriter , TextWriter errorWriter, FSharpOption`1 collectible, FSharpOption`1 msbuildEnabled) in C:\projects\fsharp-compiler-service\src\fsharp\fsi\fsi.fs:line 2877_
@dsyme
Copy link
Contributor

dsyme commented Sep 4, 2017

I would like to know if it OK to create (and run) several FSI Session concurrently?

It's not a tested scenario, I believe it could well run into problems

@goswinr
Copy link
Contributor Author

goswinr commented Sep 4, 2017

Thanks for your help @dsyme ! I want to parse and check (and maybe evaluate) several unrelated fsx files. I am using interactive sessions for that. Is the only way to do this savely to do it one after the other? Can one session parse and check code while evaluating some other code?

@dsyme
Copy link
Contributor

dsyme commented Sep 5, 2017

Thanks for your help Don! I want to parse and check (and maybe evaluate) several unrelated fsx files. I am using interactive sessions for that. Is the only way to do this safely to do it one after the other? Can one session parse and check code while evaluating some other code?

For parsing and checking, you could use the Compiler Services API (FSharpChecker). This doesn't do anything in parallel but it at least ensures that concurrent requests are serialized one by one in a thread safe way, allowing multi-threaded use of FSharpChecker objects.

In the future

  • FSiEvaluationSession is likely to be changes to use FSharpChecker for all parsing and checking, which will make it serial as well.
  • We may make FSharpChecker do parsing in parallel, and checking in serial. There's an open request for this.

But in short it's not really possible to do this stuff safely in parallel today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants