Skip to content

Commit 1cc7833

Browse files
guewenQuocDuong1306
authored andcommitted
Rename dependency method done() to on_done()
on_done() is maybe a better choice, it is less ambiguous than then() (clearer on the fact it happens on done()) and done() (less confusion with set_done()). I'll do the renaming soon, unless you have other suggestions. Ref: OCA#154 (comment)
1 parent 28b523d commit 1cc7833

5 files changed

Lines changed: 13 additions & 13 deletions

File tree

queue_job/controllers/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ def _create_graph_test_jobs(
270270
root_delayable = delayable
271271
else:
272272
tail_delayable = random.choice(tails)
273-
tail_delayable.done(delayable)
273+
tail_delayable.on_done(delayable)
274274
tails.append(delayable)
275275

276276
root_delayable.delay()

queue_job/delay.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def group(*delayables):
2727
2828
g1 = group(delayable1, delayable2)
2929
g2 = group(delayable3, delayable4)
30-
g1.done(g2)
30+
g1.on_done(g2)
3131
g1.delay()
3232
"""
3333
return DelayableGroup(*delayables)
@@ -46,7 +46,7 @@ def chain(*delayables):
4646
4747
chain1 = chain(delayable1, delayable2, delayable3)
4848
chain2 = chain(delayable4, delayable5, delayable6)
49-
chain1.done(chain2)
49+
chain1.on_done(chain2)
5050
chain1.delay()
5151
"""
5252
return DelayableChain(*delayables)
@@ -351,7 +351,7 @@ def __repr__(self):
351351
inner_graph = "\n\t".join(repr(self._graph).split("\n"))
352352
return 'DelayableChain(\n\t{}\n)'.format(inner_graph)
353353

354-
def done(self, *delayables):
354+
def on_done(self, *delayables):
355355
"""Connects the current chain to other delayables/chains/groups
356356
357357
The delayables/chains/groups passed in the parameters will be executed
@@ -406,7 +406,7 @@ def __repr__(self):
406406
inner_graph = "\n\t".join(repr(self._graph).split("\n"))
407407
return 'DelayableGroup(\n\t{}\n)'.format(inner_graph)
408408

409-
def done(self, *delayables):
409+
def on_done(self, *delayables):
410410
"""Connects the current group to other delayables/chains/groups
411411
412412
The delayables/chains/groups passed in the parameters will be executed
@@ -512,7 +512,7 @@ def set(self, *args, **kwargs):
512512
self._set_from_dict(kwargs)
513513
return self
514514

515-
def done(self, *delayables):
515+
def on_done(self, *delayables):
516516
"""Connects the current Delayable to other delayables/chains/groups
517517
518518
The delayables/chains/groups passed in the parameters will be executed

queue_job/models/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def delayable(self, priority=None, eta=None,
9494
9595
job1 = record1.delayable().do_work()
9696
job2 = record2.delayable().do_work()
97-
job1.done(job2)
97+
job1.on_done(job2)
9898
9999
The ``delay()`` call must be made on ``job1``, otherwise ``job2`` will
100100
be delayed, but ``job1`` will never be. When done on ``job1``, the

queue_job/readme/USAGE.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ which in some cases allow to build the jobs dynamically:
6060
.delay()
6161
)
6262
63-
The simplest way to define a dependency is to use ``.done(job)`` on a Delayable:
63+
The simplest way to define a dependency is to use ``.on_done(job)`` on a Delayable:
6464

6565
.. code-block:: python
6666
@@ -70,13 +70,13 @@ The simplest way to define a dependency is to use ``.done(job)`` on a Delayable:
7070
job2 = self.browse(1).delayable().generate_thumbnail((50, 50))
7171
job3 = self.browse(1).delayable().generate_thumbnail((50, 50))
7272
# job 3 is executed when job 2 is done which is executed when job 1 is done
73-
job1.done(job2.done(job3)).delay()
73+
job1.on_done(job2.on_done(job3)).delay()
7474
7575
Delayables can be chained to form more complex graphs using the ``chain()`` and
7676
``group()`` primitives.
7777
A chain represents a sequence of jobs to execute in order, a group represents
7878
jobs which can be executed in parallel. Using ``chain()`` has the same effect as
79-
using several nested ``done()`` but is more readable. Both can be combined to
79+
using several nested ``on_done()`` but is more readable. Both can be combined to
8080
form a graph, for instance we can group [A] of jobs, which blocks another group
8181
[B] of jobs. When and only when all the jobs of the group [A] are executed, the
8282
jobs of the group [B] are executed. The code would look like:

queue_job/tests/test_delayable.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ def test_graph_connect(self):
6262
node_tail2 = Delayable(self.recordset)
6363
node_middle = Delayable(self.recordset)
6464
node_top = Delayable(self.recordset)
65-
node_middle.done(node_tail)
66-
node_middle.done(node_tail2)
67-
node_top.done(node_middle)
65+
node_middle.on_done(node_tail)
66+
node_middle.on_done(node_tail2)
67+
node_top.on_done(node_middle)
6868
collected = node_top._graph._connect_graphs()
6969
self.assertEqual(
7070
collected._graph,

0 commit comments

Comments
 (0)