document service: handle dead weak reference objects

(integrated from trunk branch change 6c32ed7 by Todd Whiteman <toddw@activestate.com>)