Created task handler methods to cancel a task and check if a task exists.
Modified unit tests to use these and test methods.
unit test test_delay passes.
TaskHandler.remove method now functions. Previous it would have removed the task from the TaskHandler.tasks dictionary, but never canceled the task. Making the "remove a persistent task without executing it" incorrect. Previous there was no method to get a persistent tasks's deferral instance, which was likely why TaskHandler.remove was not used within the module.
Added unit tests to test TaskHandler.remove
Updated task handler to only return task id.
updated code within evennia that relied on the deferral directly. Including unit test for one.
all unit tests pass.
Test server functional after restarting, no issues found would telnet web client. (delay was used in the telnet module in the portal folder.
I needed to commit this before continuing forward. There is already a high line count change.
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.
Unit test for task handler tasks that complete after delay time.
Required creating local reference for a clock.
All evennia unit tests pass with `evennia test evennia`.
All of my projects unit tests passed. They have a very heavy usage of reactor.
Verified delays working with project manually
Moving forward with creating method to call callbacks early.
Any usage of taskhandler's method outside of the deferred instance calling it results in errors.
Referencing: It's easier to access these tasks (should it be necessary) using
`evennia.scripts.taskhandler.TASK_HANDLER`
I can see it is intended to be used this way.
More importantly usage of the global reactor would require usage of reactorbuilder API which is recomended for building reactors only.
Commiting notes before switching to twisted's documented methods for making and testing deferrals.
In short I need to get an instance of reactor's callLater. Creating and working with that call later will allow me to test taskhandler and make it function as intended.
Usage of utils.delay will not change.