James, thanks for pointing that out!
On 03/29/2017 10:22 AM, James Shimer wrote: > Sorry if this is a duplicate/newbie question (didn't find anything > searching). When going thru the python examples. I came across a race > condition where the thread would start to run prior to object's > constructor completing. The fix is to manually move the code generated > for starting the probe thread to the very end of the constructor. > > > If this "bug" is open already thanks for your time, if not here are some > more details: > > > Tutorial 3, section 3.1.5, you're asked to modify the probe thread to > reference members of the class to set_ampl and set_freq, those functions > in-turn access members of the object, which may not have been > initialized yet because the thread runs while the constructor is still > running. > > https://wiki.gnuradio.org/index.php/Guided_Tutorial_GNU_Radio_in_Python > > The symptom: > > Exception in thread Thread-1: > > Traceback (most recent call last): > > File > "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", > line 801, in __bootstrap_inner > > self.run() > > File > "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", > line 754, in run > > self.__target(*self.__args, **self.__kwargs) > > File "power.py", line 95, in _variable_function_probe_0_probe > > self.set_ampl(0.3) > > File "power.py", line 174, in set_ampl > > self.analog_sig_source_x_0.set_amplitude(self.ampl) > > File > "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gnuradio/gr/hier_block2.py", > line 92, in __getattr__ > > return getattr(self._impl, name) > > AttributeError: 'top_block_sptr' object has no attribute > 'analog_sig_source_x_0' > > > The resolution: > > diff -rupN if_else.py if_else2.py > > --- if_else.py2017-03-29 13:20:32.000000000 -0400 > > +++ if_else2.py2017-03-29 13:19:37.000000000 -0400 > > @@ -101,7 +101,6 @@ class if_else(gr.top_block, Qt.QWidget): > > time.sleep(1.0 / (10)) > > _variable_function_probe_0_thread = > threading.Thread(target=_variable_function_probe_0_probe) > > _variable_function_probe_0_thread.daemon = True > > - _variable_function_probe_0_thread.start() > > > > self.qtgui_time_sink_x_0 = qtgui.time_sink_f( > > 1024, #size > > @@ -160,6 +159,7 @@ class if_else(gr.top_block, Qt.QWidget): > > self.connect((self.analog_sig_source_x_0, 0), > (self.blocks_throttle_0, 0)) > > self.connect((self.analog_sig_source_x_1, 0), > (self.qtgui_time_sink_x_0, 0)) > > self.connect((self.blocks_throttle_0, 0), (self.probe, 0)) > > + _variable_function_probe_0_thread.start() > > > > def closeEvent(self, event): > > self.settings = Qt.QSettings("GNU Radio", "if_else") > > > > Thanks > > > > _______________________________________________ > Discuss-gnuradio mailing list > Discuss-gnuradio@gnu.org > https://lists.gnu.org/mailman/listinfo/discuss-gnuradio > _______________________________________________ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org https://lists.gnu.org/mailman/listinfo/discuss-gnuradio