taskhandler suppress cancel error
Added an errback to handle errors within task handler's deferred instance. Without this instances of deferred cause a traceback when a deferred is canceled without errback or callback having been called. This traceback does not end execution, and ultimately would only show to main console. Reference cancel: https://github.com/twisted/twisted/blob/trunk/src/twisted/internet/defer.py All evennia unit tests pass.
This commit is contained in:
parent
1a18b247e2
commit
c7bf773605
2 changed files with 22 additions and 2 deletions
|
|
@ -10,7 +10,7 @@ import mock
|
|||
|
||||
from django.test import TestCase
|
||||
from datetime import datetime
|
||||
from twisted.internet import task, reactor
|
||||
from twisted.internet import task
|
||||
|
||||
from evennia.utils.ansi import ANSIString
|
||||
from evennia.utils import utils
|
||||
|
|
@ -338,3 +338,9 @@ class TestDelay(EvenniaTest):
|
|||
_TASK_HANDLER.clock.advance(1) # make time pass
|
||||
self.assertEqual(self.char1.ndb.dummy_var, 'dummy_func ran')
|
||||
self.char1.ndb.dummy_var = False
|
||||
# test canceling a deferral.
|
||||
deferal_inst = utils.delay(1, dummy_func, self.char1.dbref)
|
||||
deferal_inst.cancel()
|
||||
_TASK_HANDLER.clock.advance(1) # make time pass
|
||||
self.assertEqual(self.char1.ndb.dummy_var, False)
|
||||
self.char1.ndb.dummy_var = False
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue