Skip to content

Orbit.next_orbit will Block the program completly when first called (in a python stream) and not existing. #515

@JoRadiver

Description

@JoRadiver

When vessel.orbit.next_orbit is in a stream, the first call will completly block the program until it is no longer None:
Test this code:

import krpc
import time
conn = krpc.connect()
vessel = conn.space_center.active_vessel
refframe = vessel.orbit.body.reference_frame
next_orbit = conn.add_stream(getattr, vessel.orbit, "next_orbit")
while True:
    print(next_orbit())
    time.sleep(3)

When you start it while your vessel has no next_orbit, it will just block until an next_orbit exists.
It will then work as inteded, even return None when there is no next Orbit agian.
It will also block whenever you switch to a new Vessel, which does not have a next_orbit.
Only when it is from the start, it will block.

It does not throw an exception, it just stops the program.
Seems to only be that code in Orbit.cs line 298

/// <summary>
/// If the object is going to change sphere of influence in the future, returns the new
/// orbit after the change. Otherwise returns <c>null</c>.
/// </summary>
[KRPCProperty (Nullable = true)]
public Orbit NextOrbit {
      get { return (double.IsNaN (TimeToSOIChange)) ? null : new Orbit (InternalOrbit.nextPatch); }
}

Dont't know c# really yet, can't see any problems here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions