def _teardown(self):
""" restore radio and wait on tuning thread"""
clean = True
self._err = ""
# restore the radio - this will have the side effect of
# causing the threads to error out and quit
try:
if self._card:
phy = self._card.phy
pyw.devdel(self._card)
card = pyw.phyadd(phy,self._dev,self._dinfo['mode'])
pyw.up(card)
except pyric.error as e:
clean = False
self._err = "ERRNO {0} {1}".format(e.errno, e.strerror)
# join threads, waiting a short time before continuing
try:
self._tuner.join(5.0)
except (AttributeError,RuntimeError):
# either tuner is None, or it never started
pass
try:
self._sniffer.join(5.0)
except (AttributeError, RuntimeError):
# either sniffer is None, or it never started
pass
if threading.active_count() > 0:
clean = False
self._err += "One or more workers failed to stop"
return clean
评论列表
文章目录