From 0ab66ae04541f344fa61cb8d0e7d496203176d3d Mon Sep 17 00:00:00 2001 From: John Davis Date: Fri, 8 Sep 2023 14:02:12 -0400 Subject: [PATCH] Provide better guidance on what to override --- doc/source/dev/build_a_job_runner.rst | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/doc/source/dev/build_a_job_runner.rst b/doc/source/dev/build_a_job_runner.rst index d289e92027f1..4a0e053034bf 100644 --- a/doc/source/dev/build_a_job_runner.rst +++ b/doc/source/dev/build_a_job_runner.rst @@ -24,17 +24,27 @@ contains the base runner implementation. To create a new runner, the base runner class (in most cases, ``AsynchronousJobRunner``) must be inherited and only certain methods need to be overridden with your logic. -These are the methods that need to be implemented, with custom logic added as needed: +These are the methods that need to be implemented: -1. ``__init__(app, nworkers, **kwargs)`` +1. ``queue_job(job_wrapper)`` -2. ``queue_job(job_wrapper)`` +2. ``check_watched_item(job_state)`` -3. ``check_watched_item(job_state)`` +3. ``stop_job(job)`` -4. ``stop_job(job)`` +4. ``recover(job, job_wrapper)`` -5. ``recover(job, job_wrapper)`` +In addition, you will almost certainly override the ``__init__(app, nworkers, **kwargs)`` +method in order to add custom logic to initialize your runner. In +doing so, make sure to call the parent class constructor: + +.. code-block:: python + + super().__init__(app, nworkers, **kwargs) + +Keep in mind that when you override a method, you should not reimplement any of +the logic that is present in the base class: the above call to ``super()`` +ensures that all that such logic is handled automatically. The big picture ---------------