Merge lp:~cjwatson/ampoule/process-error-not-ready into lp:ampoule

Proposed by Colin Watson on 2017-09-15
Status: Needs review
Proposed branch: lp:~cjwatson/ampoule/process-error-not-ready
Merge into: lp:ampoule
Diff against target: 44 lines (+13/-3)
2 files modified
ampoule/pool.py (+1/-1)
ampoule/test/test_process.py (+12/-2)
To merge this branch: bzr merge lp:~cjwatson/ampoule/process-error-not-ready
Reviewer Review Type Date Requested Status
dialtone 2017-09-15 Pending
Review via email: mp+330848@code.launchpad.net

Commit Message

Don't add a process back to the ready set if it received an error such as a timeout.

Description of the Change

This stops calls from being dispatched to a worker that just timed out and is about to be killed.

To post a comment you must log in.

Unmerged revisions

47. By Colin Watson on 2017-09-15

Don't add a process back to the ready set if it received an error such as a timeout.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ampoule/pool.py'
2--- ampoule/pool.py 2012-04-13 03:27:08 +0000
3+++ ampoule/pool.py 2017-09-15 17:16:28 +0000
4@@ -223,7 +223,7 @@
5 cancelCall(timeoutCall)
6 cancelCall(deadlineCall)
7 self.busy.discard(child)
8- if not die:
9+ if not die and not is_error:
10 # we are not marked to be removed, so add us back to
11 # the ready set and let's see if there's some catching
12 # up to do
13
14=== modified file 'ampoule/test/test_process.py'
15--- ampoule/test/test_process.py 2012-04-13 03:27:08 +0000
16+++ ampoule/test/test_process.py 2017-09-15 17:16:28 +0000
17@@ -781,15 +781,25 @@
18 ).addCallback(lambda _: pp.stop())
19
20 def processTimeoutTest(self, timeout):
21+ """
22+ A call with a timeout is correctly terminated, and the process pool
23+ starts a new worker so that it can handle further calls.
24+ """
25 pp = pool.ProcessPool(WaitingChild, min=1, max=1)
26+ ECHO_STRING = "hello"
27
28- def _work(_):
29+ def _first(_):
30 d = pp.callRemote(First, data="ciao", _timeout=timeout)
31 self.assertFailure(d, error.ProcessTerminated)
32 return d
33
34+ def _echo(_):
35+ return pp.callRemote(commands.Echo, data=ECHO_STRING
36+ ).addCallback(self.assertEqual, {"response": ECHO_STRING})
37+
38 return pp.start(
39- ).addCallback(_work
40+ ).addCallback(_first
41+ ).addCallback(_echo
42 ).addCallback(lambda _: pp.stop())
43
44 def test_processTimeout(self):

Subscribers

People subscribed via source and target branches