(Adding the list back in - I meant to reply-all before...) Simon, Yes, the obj solution should work just fine - I was wondering about that parameter and the approach makes sense to me. Thanks! Rocky On Mon, Mar 30, 2020 at 2:38 PM Simon Marchi wrote: > On 2020-03-30 4:24 p.m., Rocky Dunlap wrote: > > Simon, > > > > In my case, after the graph completes, I was trying to access the sink > instances in order to collect some statistics collected inside the instance > during the graph run. I guess then the question is how are the graph > components supposed to communicate with the outside world in general, such > as filling in some Python data structures with info from a trace for > post-processing or further analysis in Python? Or is the expectation that > sink components will retain no state at all after the graph completes? > > > > Rocky > > Hi Rocky, > > Was it your intention to not do a reply-all? I think this would be good > info for all to read. If not, > please do a reply-all and I'll replay again what I wrote below on the list. > > Of course the sinks are expected to produce some result outside of their > own little internal state. For > sinks that produce some trace files, they'll typically write on the > filsystem (like sink.ctf.fs). > > But if you want to send some results to another Python object/data > structure, the `obj` parameter of > `add_component` is pretty much meant for that. You can pass in a > reference to a Python object, and > the component receives it in its `__init__`. We thought that this could > be useful, for example, if > the sink needs to receive a connection handle to a database, for example. > That handle can be created > outside of the sink and passed it when instantiating the component. Think > of it like some void* user > data in C. > > In your case, you could create whatever object you need to collect your > statistics/results, and pass > a reference to it. > > Here's an example in the tests: > > > https://github.com/efficios/babeltrace/blob/8b305066676fc7aa433e8eb668f9de8802008025/tests/bindings/python/bt2/test_graph.py#L106-L120 > > Does that help? > > Simon >