Cells get executed using different threads
See original GitHub issueCells get executed using different threads
This is a design question and a possible bug.
As you execute different cells in a C# or F# notebook, a different thread gets used for each interaction. The question is really whether we want to guarantee that the same thread gets used each time you execute a new cell. Since cell execution is inherently linear it feels we should likely guarantee this.
For example, repeated re-execution of
System.Console.WriteLine("{0}", System.Threading.Thread.CurrentThread.ManagedThreadId);
gives 10, 11 etc.
This came up when using TensorFlow.NET, which had some thread local storage that was not getting re-initialized correctly as operations were performed from different threads. But the question is more general too - is is something we want to guarantee or not, and we should document it either way.
Please complete the following:
- OS
- Any
- Browser
- Any
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:15 (8 by maintainers)
Top Results From Across the Web
Run cells in different threads · Issue #1155 · jupyter/notebook
Hi,. Sometimes I run long code in some cell, and still want to be able to run small snippets (independant) in another cell....
Read more >Multithreaded recalculation in Excel
Excel tries to identify parts of the calculation chain that can be recalculated concurrently on different threads. The following very simple ...
Read more >sql table cell modified by multiple threads at the same time
If the problem is that several threads read and set the value at almost the same time, and reads and writes don't arrive...
Read more >What is multithreading?
With multithreading, while the computer system's processor executes one instruction at a time, different threads from multiple programs are executed so fast it ......
Read more >Reading Cell Values in Multiple Threads Simultaneously
Needing to read cell values in multiple threads simultaneously is a common requirement. This article explains how to use Aspose.Cells for this purpose....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Either I am misunderstanding something, or library code should not be affected. All new tasks started from interactive should use standard
SynchronizationContext
and can execute on any worker thread. Single thread should only affect the top-level call.I don’t think this is realistic. The TensorFlow threading model is not particularly strange and it’s not possible to go round patching up the package ecosystem to include dependencies on .NET Interactive
We should just make it possible to configure .NET Interactive to respect a single-threaded execution model without any changes to package ecosystems. A magic command would be enough.
@lostmsu We should work together to get a proposed fix for this I think.