commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r7442 - gnuradio/trunk/gr-usrp/src


From: jcorgan
Subject: [Commit-gnuradio] r7442 - gnuradio/trunk/gr-usrp/src
Date: Tue, 15 Jan 2008 12:54:24 -0700 (MST)

Author: jcorgan
Date: 2008-01-15 12:54:22 -0700 (Tue, 15 Jan 2008)
New Revision: 7442

Modified:
   gnuradio/trunk/gr-usrp/src/usrp.py
Log:
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.


Modified: gnuradio/trunk/gr-usrp/src/usrp.py
===================================================================
--- gnuradio/trunk/gr-usrp/src/usrp.py  2008-01-15 19:42:03 UTC (rev 7441)
+++ gnuradio/trunk/gr-usrp/src/usrp.py  2008-01-15 19:54:22 UTC (rev 7442)
@@ -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 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 @@
     @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):





reply via email to

[Prev in Thread] Current Thread [Next in Thread]