Commit graph

209 commits

Author SHA1 Message Date
Griatch
ecd4307a87 Add stop_task kwarg to help Script delete-on-stop. Resolve #2455. 2021-08-03 22:15:41 +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
7147e3e027 Prepare all .po files for updating by volunteers 2021-05-29 18:30:20 +02:00
Griatch
8837b93dd2 Update localization 2021-05-29 13:22:19 +02:00
Griatch
7ff8cbb341 I18n string cleanup and refactoring 2021-05-27 17:37:26 +02:00
Griatch
1bdcafcef4 Migrating models, many admin tweaks 2021-05-20 23:43:46 +02:00
Griatch
8e02be23e4 Trying to relocate admin (not working yet) 2021-05-16 23:40:31 +02:00
Griatch
beecefc19f Resolve merge conflicts with master 2021-05-09 15:31:24 +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
e1762c8b2f Update scripts command, Scripts documentation 2021-03-07 17:41:48 +01:00
Griatch
b5195a6e96 [feat] Script refactor; decouple timer component from script lifetime. Resolve #1715 2021-03-07 10:34:01 +01:00
Griatch
a5506d4e85 Better handle error when trying to add ticker with subsecond interval. Resolves #2235 2020-11-12 22:34:44 +01:00
Griatch
e4b1e1c9aa Better handle error when trying to add ticker with subsecond interval. Resolves #2235 2020-11-12 22:01:24 +01:00
Griatch
91e2e68291 Optimize _Saverdict.update that caused issues for webclient option update (#2224) 2020-11-01 11:32:12 +01:00
Griatch
6f3548eea9 Optimize _Saverdict.update that caused issues for webclient option update (#2224) 2020-11-01 11:19:14 +01:00
Griatch
b449ebe3d4 Fix style to Keyword Args 2020-10-12 21:13:06 +02:00
Griatch
d414cc3ccd Start add docs again 2020-10-08 21:45:18 +02:00
Griatch
443310b1c4 [Resolve merge conflicts 2020-09-19 14:19:40 +02:00
Griatch
a3c34f5f39 Run black on sources 2020-09-19 14:02:03 +02:00
Griatch
a3923a825e Resolve merge conflicts 2020-09-19 00:38:04 +02:00
Griatch
7af702055b Make TickerHandler handle malformed input cleaner. Resolve #2191 2020-09-18 22:03:38 +02:00
Griatch
9cdc37355c Resolve merge conflicts 2020-09-16 23:49:05 +02:00
luyijun
e69cce9925 Fix a bug that script whose db_interval is 0 will be run when call its start method twice. 2020-08-02 10:48:47 +08:00
Griatch
94cf728081 Merge changes from master 2020-07-15 18:07:45 +02:00
Griatch
7fed14d233 Rename docstring Kwargs to Keyword Args 2020-07-10 15:57:57 +02:00
Griatch
0c53f1bcc3 Fix return type for all situations of get_all_scripts manager method, as inspired by #2117 2020-06-28 11:37:17 +02:00
Griatch
25a0de12d7 Ran black on sources 2020-02-29 12:25:00 +01:00
Griatch
edcd06d531 Handle case of script.at_repeat() immediately calling stop(). Resolves #2061. 2020-02-29 12:24:26 +01:00
Griatch
49b34f390d Don't allow step_task if task is None. Resolves #2047 2020-02-12 23:13:52 +01:00
trhr
090157979b django.utils.translation.ugettext(), ugettext_lazy(), ugettext_noop(), ungettext(), and ungettext_lazy() are deprecated in favor of the functions that they’re aliases for: django.utils.translation.gettext(), gettext_lazy(), gettext_noop(), ngettext(), and ngettext_lazy(). 2020-02-09 20:14:47 -06:00
Griatch
7a8d5853af Some minor tweaks. 2020-01-28 19:40:15 +01:00