Commit graph

39 commits

Author SHA1 Message Date
Griatch
c476121a6c Make TaskHandler properly handle missing attribute on server reload. Resolve #3620 2024-09-29 12:57:19 +02:00
Griatch
c5a4a34bac Apply black to codes 2024-04-01 17:51:05 +02:00
Griatch
e5d07603ca Run black. Resolve circular import issues in components contrib. 2024-02-25 19:03:11 +01:00
Griatch
42aba18ada Add OnDemandHandler to support on-demand timers easier 2024-02-04 00:38:47 +01:00
Griatch
a461a97576 Format code imports 2022-11-10 22:21:12 +01:00
Griatch
cbaf9151c2 Refactored turn based combat tutorial 2022-07-03 22:12:23 +02:00
Griatch
2478698216 Fix merge conflicts 2021-06-19 15:59:09 +02:00
Griatch
b80fe31d04 Fix taskhandler pickling method instances. Resolves #2439 2021-06-19 15:57:36 +02:00
Griatch
3deb8f48c1 Merge branch 'master' into develop 2021-06-19 15:33:08 +02:00
Griatch
41986e1288 Try reporting a little more info from taskhandler deserialization error 2021-06-18 19:34:44 +02:00
Griatch
7ff8cbb341 I18n string cleanup and refactoring 2021-05-27 17:37:26 +02:00
Griatch
bf4af8b208 Fix edge case in TaskHandler when un-pickleable callable supplied 2021-05-09 15:25:57 +02:00
davewiththenicehat
248c884605 doc strings updates.
doc strings updates.

Unit tests pass at default run level.
2021-04-30 11:26:49 -04:00
davewiththenicehat
99568148c6 task handler unit test revamp & bugfix
revamped task handler unit tests

found bug when a False persistent kwarg is passed to the add method. Resolved it.

All evennia unit tests pass. Default run level and run level 2.
2021-04-26 08:59:35 -04:00
davewiththenicehat
84193dd9a7 task handler update
updating taskhandler.py before updating unit tests.

All evennia unit tests pass.
2021-04-25 22:38:35 -04:00
davewiththenicehat
3cc14e2e4c task handler call_task, Task.call methods created
task handler call_task, Task.call methods created

Added unit tests for these methods.

All evennia unit tests pass
2021-04-19 17:36:42 -04:00
davewiththenicehat
0b7cae600a task handler remove_all method created. task handler server restart unit test created.
Added method remove_all to task handler. (intended for unit testing)
Created a method to mimic a server restart for the purpose of task handler.

test_delay unit test passes.
2021-04-19 17:16:37 -04:00
davewiththenicehat
fea077d555 task handler automatic stale task cleanup
Task handler will automatically remove uncalled but canceled from task handler. By default this will not occur until a canceled task has been uncalled for 60 second after the time it should have been called. To adjust this time use TASK_HANDLER.stale_timeout. If stale_timeout is 0 stale tasks will not be automatically removed.
This is not done on a timer. I is done as new tasks are added or the load method is called.

Added unit tests to test automatic removal. Including when it should not automatically removed. Both when it is too soon, or when the stale_timeout attribute is set to 0.
2021-04-19 09:37:19 -04:00
davewiththenicehat
f57fb645c8 taskhandler.Task created
Created an object to represent a task.
This allows for the return of TASK_HANDLER.add or utils.delay to be an object that has callable methods. It has been created to mock the most common methods and attributes of a twisted deferred object.

Changed test_utils.test_delay for new usage.
Returned previously changed modules slow_exit, tutorial_world.objects and portal.telnet to their previous states. As the return of utils.delay can be used as if it were a deferred.

All evennia unit tests pass
2021-04-18 18:25:39 -04:00
davewiththenicehat
16f6edb18d TaskHandler.do_task is now state aware & can return callback's return
TaskHandler.do_task is now state aware and can be called manually.
It can now return the callbacks returns.

added unit tests to verify early callback is functional. Both persistent and non-persistent tasks.

All evennia unit tests pass.
2021-04-18 11:01:45 -04:00
davewiththenicehat
bbc60b0340 TaskHandler.active method created
TaskHandler.active method created to check if a task is currently active.

test_delay unit test passes.
2021-04-18 09:59:45 -04:00
davewiththenicehat
af44237838 TaskHandler cancel and exists method's created
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.
2021-04-18 09:50:54 -04:00
davewiththenicehat
f3b546bcf6 TaskHandler.remove() made functional
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
2021-04-18 08:51:18 -04:00
davewiththenicehat
97f7806348 task handler, updated to only return task id
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.
2021-04-18 00:43:09 -04:00
davewiththenicehat
c7bf773605 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.
2021-04-16 10:55:24 -04:00
davewiththenicehat
1a18b247e2 Task_Handler unit test, after completion time only
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.
2021-04-14 12:14:04 -04:00
davewiththenicehat
f62ff2015f taskhandler verified do_task causes errors if called manually (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.
2021-04-13 17:01:55 -04:00
davewiththenicehat
f445cfb355 TaskHandler Return task_id if persistent
TaskHandler Return task_id if persistent

unit tests passed 645 ran
2021-04-07 18:00:02 -04:00
Griatch
d414cc3ccd Start add docs again 2020-10-08 21:45:18 +02:00
Griatch
c2c7fa311a Format code with black. Add makefile to run fmt/tests 2019-09-28 18:18:11 +02:00
Griatch
72f4fedcbe Merge with develop and fix merge conflicts 2018-10-01 20:58:16 +02:00
Griatch
74e8c74f80 Work towards resolving unittests with deferreds 2018-01-02 21:21:57 +01:00
Ryan Stein
f2e800ddf1 Unwrap several for statements from 2to3 conversion process. 2017-11-02 12:46:33 -04:00
Ryan Stein
6fa280b9fd Run 2to3. 2017-10-29 13:40:30 -04:00
Vincent Le Goff
3176f4b100 Fix a bug in the permanent delay when the object is destroyed 2017-08-31 21:38:49 +02:00
Griatch
92df3ce5ae Structure handlers to allow .get() to return lists
See #1154. In the end I didn't modify the Attributehandler and
TagHandler like this, instead I added the `return_list` argument
for cases when one wants a guaranteed return.
2017-08-27 14:56:05 +02:00
Griatch
b278337172 Make PEP8 cleanup of line spaces and character distances as well as indents 2017-08-19 23:16:36 +02:00
Vincent Le Goff
8ef50f3706 Fix a minor mistake in the task handler 2017-08-10 11:40:57 +02:00
Vincent Le Goff
37c9d65a9d Place the persistent task in a task handler 2017-08-08 19:47:22 +02:00
Renamed from evennia/utils/persistent.py (Browse further)