2006-05-24 22:16:36 +00:00
|
|
|
# -*- coding: iso-8859-1 -*-
|
2009-01-08 14:18:03 +00:00
|
|
|
# Copyright (C) 2006-2009 Bastian Kleineidam
|
2006-05-24 22:16:36 +00:00
|
|
|
#
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
#
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
#
|
2009-07-24 21:58:20 +00:00
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2006-05-24 22:16:36 +00:00
|
|
|
import thread
|
2008-05-09 06:16:03 +00:00
|
|
|
from ..decorators import notimplemented
|
|
|
|
|
from .. import log, LOG_CHECK, threader
|
|
|
|
|
from . import console
|
2006-05-24 22:16:36 +00:00
|
|
|
|
|
|
|
|
|
2008-05-09 06:16:03 +00:00
|
|
|
class CheckedTask (threader.StoppableThread):
|
2007-11-29 07:50:22 +00:00
|
|
|
"""Stoppable URL check task, handling error conditions while running."""
|
2006-05-24 22:16:36 +00:00
|
|
|
|
|
|
|
|
def run (self):
|
2007-11-29 07:50:22 +00:00
|
|
|
"""Handle keyboard interrupt and other errors."""
|
2006-05-24 22:16:36 +00:00
|
|
|
try:
|
|
|
|
|
self.run_checked()
|
|
|
|
|
except KeyboardInterrupt:
|
2008-04-27 11:39:21 +00:00
|
|
|
log.warn(LOG_CHECK, "interrupt did not reach the main thread")
|
2006-05-24 22:16:36 +00:00
|
|
|
thread.interrupt_main()
|
2008-04-27 11:39:21 +00:00
|
|
|
except Exception:
|
2006-06-03 01:14:05 +00:00
|
|
|
console.internal_error()
|
2006-05-24 22:16:36 +00:00
|
|
|
|
2008-05-09 06:16:03 +00:00
|
|
|
@notimplemented
|
2006-05-25 14:25:04 +00:00
|
|
|
def run_checked (self):
|
2007-11-29 07:50:22 +00:00
|
|
|
"""Overload in subclass."""
|
2006-05-25 14:25:04 +00:00
|
|
|
pass
|