Weird threading problem

Hi,

So I made a loopback graph (file source, modulator, demodulator, file
sink) with a short 1K file in it. The following code works (runs and
exits without any exceptions):

    graph = loopback_graph()
    print "starting"
    graph.start()
    print "started"
    print "stopping"
    graph.stop()
    print "done"

As does the following:

    graph = loopback_graph()
    print "starting"
    graph.start()
    print "started"
    for x in range(1000):
        for y in range(10000):
            pass

print “stopping”

graph.stop()

    print "done"

But this does not:

    graph = loopback_graph()
    print "starting"
    graph.start()
    print "started"

for x in range(1000):

for y in range(10000):

pass

print “stopping”

graph.stop()

    print "done"

It exits with this inscrutable message:

>>> gr_fir_ccf: using SSE
starting
started
done
Unhandled exception in thread started by
Error in sys.excepthook:

Original exception was:

So, discussion:

A) Case 2 should really print an exception, or a warning, or something
right? Why would the application exit without any errors if I haven’t
stopped the flow graph? Or is it automatically stopped by the
file_source exhausting its input?

B) There must be some competing thread issue in Case 3 that makes things
go crazy, right? I should note I’m running this on a Intel® XEON™
CPU 2.20GHz with “4” cores - I think it has two multithreaded cores. I’m
not sure, it’s a few years old, but I’ve run into all kinds of weird
thread problems in my apps on this machine that don’t pop up in other
machines with single cores or with a dual-core Athlon X2 TL-50.

-Dan

On Wed, Mar 28, 2007 at 03:57:14PM -0700, Dan H. wrote:

    print "stopping"
    graph.stop()
    print "done"

Uhh, if you want the graph to finish before you kill it with stop(),
I suggest:

    graph = loopback_graph()
    print "starting"
    graph.start()
    print "started"
    print "waiting"
    graph.wait()
    print "done"

graph.stop()

pass

Unhandled exception in thread started by
Error in sys.excepthook:

Original exception was:

So, discussion:

A) Case 2 should really print an exception, or a warning, or something
right? Why would the application exit without any errors if I haven’t
stopped the flow graph? Or is it automatically stopped by the
file_source exhausting its input?

It’s stopped when the graph exhausts it’s input (from the file source).

B) There must be some competing thread issue in Case 3 that makes things
go crazy, right? I should note I’m running this on a Intel® XEON™
CPU 2.20GHz with “4” cores - I think it has two multithreaded cores. I’m
not sure, it’s a few years old, but I’ve run into all kinds of weird
thread problems in my apps on this machine that don’t pop up in other
machines with single cores or with a dual-core Athlon X2 TL-50.

-Dan

Hi Dan,

Does either the modulator or demodulator talk to python via messages?

Can you try this experiment again, using “wait” instead of “stop”?

If it still raises the exception, you you include the complete
traceback?

Thanks,
Eric

On Wed, Mar 28, 2007 at 09:15:17PM -0700, Dan H. wrote:

running with neither that there were exceptions when I didn’t pause the
main program (I presume, to let the data finish).

-Dan

OK

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs