GstPbutils info appears to be empty

I’m trying to pull duration using GstPbutils so that I don’t have to depend on a pipeline. The discovered signal successfully gets emitted and the result is OK, suggesting that it successfully discovered the file. However, info.get_duration() always returns 0.

def get_duration(uri: str) -> int:
    uri = Path(uri).resolve().as_uri();
    duration = 0;

    def discovered(d, info, err):
        nonlocal duration;
        result = info.get_result();
        if result == GstPbutils.DiscovererResult.OK:
            duration = info.get_duration();

    d = * Gst.SECOND);
    d.connect('discovered', discovered);
    return duration;

I don’t know what’s wrong. My code is based on subprojects/gst-python/examples/gst-discover · main · GStreamer / gstreamer · GitLab

Does running gst-discoverer-1.0 -v yourfile.mkv show the duration correctly?

Yes, it does. It lists container info, duration, codec: everything I expect it to.

Is the result OK?

Do you get a duration value when you print it inside the fn discovered()?

The result is OK and printing the result of info.get_duration() from within the discovered callback always prints out 0.