Changeset 7442

Show
Ignore:
Timestamp:
01/15/08 12:54:22
Author:
jcorgan
Message:

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.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gnuradio/trunk/gr-usrp/src/usrp.py

    r7352 r7442  
    11# 
    2 # Copyright 2004,2005 Free Software Foundation, Inc. 
     2# Copyright 2004,2005,2007 Free Software Foundation, Inc. 
    33#  
    44# This file is part of GNU Radio 
     
    2727from gnuradio import gru 
    2828from usrpm.usrp_fpga_regs import * 
     29import weakref 
    2930 
    3031FPGA_MODE_NORMAL   = usrp1.FPGA_MODE_NORMAL 
     
    381382    @param subdev_spec: return value from subdev option parser.   
    382383    @type  subdev_spec: (side, subdev), where side is 0 or 1 and subdev is 0 or 1 
    383     @returns: an instance derived from db_base 
     384    @returns: an weakref to an instance derived from db_base 
    384385    """ 
    385386    side, subdev = subdev_spec 
    386     return u.db[side][subdev] 
     387    # Note: This allows db to go out of scope at the right time 
     388    return weakref.proxy(u.db[side][subdev]) 
    387389 
    388390