Skip to content

Commit 181f3d0

Browse files
committed
Add operator to get runtime object
1 parent 16b1443 commit 181f3d0

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System;
2+
using System.ComponentModel;
3+
4+
namespace Bonsai.Scripting.Python
5+
{
6+
/// <summary>
7+
/// Represents an operator that gets the Python runtime object which can be used
8+
/// to import modules, evaluate expressions, and pass data to and from Python.
9+
/// </summary>
10+
/// <remarks>
11+
/// The runtime object notification is emitted while holding the global interpreter lock.
12+
/// </remarks>
13+
[Description("Gets the Python runtime object which can be used to import modules, evaluate expressions, and pass data to and from Python.")]
14+
public class GetRuntime : Source<RuntimeManager>
15+
{
16+
/// <summary>
17+
/// Wraps an observable sequence to ensure all notifications are emitted
18+
/// while holding the Python global interpreter lock.
19+
/// </summary>
20+
/// <returns>
21+
/// An observable sequence that returns the active <see cref="RuntimeManager"/>
22+
/// object on subscription. The value is emitted while holding the global
23+
/// interpreter lock.
24+
/// </returns>
25+
public override IObservable<RuntimeManager> Generate()
26+
{
27+
return RuntimeManager.RuntimeSource.ObserveOnGIL();
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)