# Buggy code
def __init__(self, parent):
    self._logger = logging.getLogger(self.__class__.__name__)

    self._logger.debug("CreditMiningPanel: __init__")

    self.guiutility = GUIUtility.getInstance()
    self.utility = self.guiutility.utility
    self.installdir = self.utility.getPath()

    FancyPanel.__init__(self, parent, border=wx.BOTTOM)

    self.SetBorderColour(SEPARATOR_GREY)
    self.SetBackgroundColour(GRADIENT_LGREY, GRADIENT_DGREY)

    if not self.utility.session.get_creditmining_enable():
        wx.StaticText(self, -1, "Credit mining inactive")
        return

    self.tdb = self.utility.session.open_dbhandler(NTFY_TORRENTS)
    self.boosting_manager = self.utility.session.lm.boosting_manager

    self.main_sizer = wx.BoxSizer(wx.VERTICAL)

    self.header = self.create_header_info(self)
    if self.header:
        self.main_sizer.Add(self.header, 0, wx.EXPAND)

    self.main_splitter = wx.SplitterWindow(self, style=wx.SP_BORDER)
    self.main_splitter.SetMinimumPaneSize(300)

    self.sourcelist = CpanelCheckListCtrl(
        self.main_splitter,
        -1,
        agwStyle=wx.LC_REPORT
        | wx.LC_NO_HEADER
        | wx.LC_VRULES
        | wx.LC_HRULES
        | wx.LC_SINGLE_SEL
        | ULC.ULC_HAS_VARIABLE_ROW_HEIGHT,
    )

    self.add_components(self.main_splitter)
    self.SetSizer(self.main_sizer)

    self.guiutility.utility.session.lm.threadpool.add_task(
        self._post_init, 2, task_name=str(self) + "_post_init"
    )


# Traceback (isError)
Regression

Tribler.Test.Core.Modules.RestApi.test_downloads_endpoint.TestDownloadsEndpoint.test_remove_download_no_remove_data_param (from nosetests)
Failing for the past 1 build (Since Failed#2109 )
Took 4.4 sec.
Error Message

Test raised 1 unhandled Twisted exceptions:
[{'log_namespace': u'log_legacy', 'log_time': 1467938979.639, 'format': '%(log_legacy)s', 'log_system': '-', 'log_legacy': <twisted.logger._stdlib.StringifiableFromEvent object at 0x06D22830>, 'log_level': <LogLevel=critical>, 'system': '-', 'isError': 1, 'failure': <twisted.python.failure.Failure exceptions.AttributeError: 'NoneType' object has no attribute 'add_task'>, 'time': 1467938979.639, 'log_text': 'Unhandled Error\nTraceback (most recent call last):\n  File "C:\\Python27\\lib\\threading.py", line 763, in run\n    self.__target(*self.__args, **self.__kwargs)\n  File "C:\\workspace\\jenkins\\workspace\\GH_Tribler_PR_tests_win32\\tribler\\Tribler\\Core\\Utilities\\twisted_thread.py", line 55, in _reactor_runner\n    reactor.run(installSignalHandlers=False)\n  File "C:\\Python27\\lib\\site-packages\\twisted\\internet\\base.py", line 1194, in run\n    self.mainLoop()\n  File "C:\\Python27\\lib\\site-packages\\twisted\\internet\\base.py", line 1203, in mainLoop\n    self.runUntilCurrent()\n--- <exception caught here> ---\n  File "C:\\Python27\\lib\\site-packages\\twisted\\internet\\base.py", line 825, in runUntilCurrent\n    call.func(*call.args, **call.kw)\n  File "C:\\workspace\\jenkins\\workspace\\GH_Tribler_PR_tests_win32\\tribler\\Tribler\\Core\\Libtorrent\\__init__.py", line 27, in <lambda>\n    lambda_f = lambda a = args, kwa = kwargs: invoke_func(*a, **kwa)\n  File "C:\\workspace\\jenkins\\workspace\\GH_Tribler_PR_tests_win32\\tribler\\Tribler\\Core\\Libtorrent\\__init__.py", line 28, in invoke_func\n    download.session.lm.threadpool.add_task(lambda_f, 1)\nexceptions.AttributeError: \'NoneType\' object has no attribute \'add_task\'\n', 'log_format': u'{log_text}', 'message': (), 'why': None}]

# Fixed code
def __init__(self, parent):
    self._logger = logging.getLogger(self.__class__.__name__)

    self._logger.debug("CreditMiningPanel: __init__")

    self.guiutility = GUIUtility.getInstance()
    self.utility = self.guiutility.utility
    self.installdir = self.utility.getPath()

    FancyPanel.__init__(self, parent, border=wx.BOTTOM)
    TaskManager.__init__(self)

    self.SetBorderColour(SEPARATOR_GREY)
    self.SetBackgroundColour(GRADIENT_LGREY, GRADIENT_DGREY)

    if not self.utility.session.get_creditmining_enable():
        wx.StaticText(self, -1, "Credit mining inactive")
        return

    self.tdb = self.utility.session.open_dbhandler(NTFY_TORRENTS)
    self.boosting_manager = self.utility.session.lm.boosting_manager

    self.main_sizer = wx.BoxSizer(wx.VERTICAL)

    self.header = self.create_header_info(self)
    if self.header:
        self.main_sizer.Add(self.header, 0, wx.EXPAND)

    self.main_splitter = wx.SplitterWindow(self, style=wx.SP_BORDER)
    self.main_splitter.SetMinimumPaneSize(300)

    self.sourcelist = CpanelCheckListCtrl(
        self.main_splitter,
        -1,
        agwStyle=wx.LC_REPORT
        | wx.LC_NO_HEADER
        | wx.LC_VRULES
        | wx.LC_HRULES
        | wx.LC_SINGLE_SEL
        | ULC.ULC_HAS_VARIABLE_ROW_HEIGHT,
    )

    self.add_components(self.main_splitter)
    self.SetSizer(self.main_sizer)

    self.register_task(str(self) + "_post_init", reactor.callLater(2, self._post_init))