diff options
author | jcorgan | 2008-01-15 19:54:22 +0000 |
---|---|---|
committer | jcorgan | 2008-01-15 19:54:22 +0000 |
commit | 9949abfaf792fd860cb6d73775b53b655ca5417b (patch) | |
tree | 8ab28357b51792e1639e24998c6a2e43ed426f9b | |
parent | c134910514da25ea27142022c90fe384395668e4 (diff) | |
download | gnuradio-9949abfaf792fd860cb6d73775b53b655ca5417b.tar.gz gnuradio-9949abfaf792fd860cb6d73775b53b655ca5417b.tar.bz2 gnuradio-9949abfaf792fd860cb6d73775b53b655ca5417b.zip |
Change usrp.selected_subdev() to return a weak reference to the
daughterboard object. This fixes the 'weakref exception' error on
shutdown that is sometimes seen. What was happening is that user
code would hold a daughterboard reference, the USRP object would go
out of scope, and then when the daughterboard finally went out of scope,
it's destructor would try to invoke methods on (the now non-existent)
USRP.
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@7442 221aa14e-8319-0410-a670-987f0aec2ac5
-rw-r--r-- | gr-usrp/src/usrp.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/gr-usrp/src/usrp.py b/gr-usrp/src/usrp.py index 6b2f3d46f..f149a3ff8 100644 --- a/gr-usrp/src/usrp.py +++ b/gr-usrp/src/usrp.py @@ -1,5 +1,5 @@ # -# Copyright 2004,2005 Free Software Foundation, Inc. +# Copyright 2004,2005,2007 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -26,6 +26,7 @@ from usrpm import usrp_dbid from gnuradio import usrp1 # usrp Rev 1 and later from gnuradio import gru from usrpm.usrp_fpga_regs import * +import weakref FPGA_MODE_NORMAL = usrp1.FPGA_MODE_NORMAL FPGA_MODE_LOOPBACK = usrp1.FPGA_MODE_LOOPBACK @@ -380,10 +381,11 @@ def selected_subdev(u, subdev_spec): @param u: an instance of usrp.source_* or usrp.sink_* @param subdev_spec: return value from subdev option parser. @type subdev_spec: (side, subdev), where side is 0 or 1 and subdev is 0 or 1 - @returns: an instance derived from db_base + @returns: an weakref to an instance derived from db_base """ side, subdev = subdev_spec - return u.db[side][subdev] + # Note: This allows db to go out of scope at the right time + return weakref.proxy(u.db[side][subdev]) def calc_dxc_freq(target_freq, baseband_freq, fs): |