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

Proposed by Colin Watson
Status: Work in progress
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 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.
Revision history for this message
Colin Watson (cjwatson) wrote :

This was fixed slightly differently in the new upstream location: https://github.com/twisted/ampoule/pull/30

Unmerged revisions

47. By Colin Watson

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
=== modified file 'ampoule/pool.py'
--- ampoule/pool.py 2012-04-13 03:27:08 +0000
+++ ampoule/pool.py 2017-09-15 17:16:28 +0000
@@ -223,7 +223,7 @@
223 cancelCall(timeoutCall)223 cancelCall(timeoutCall)
224 cancelCall(deadlineCall)224 cancelCall(deadlineCall)
225 self.busy.discard(child)225 self.busy.discard(child)
226 if not die:226 if not die and not is_error:
227 # we are not marked to be removed, so add us back to227 # we are not marked to be removed, so add us back to
228 # the ready set and let's see if there's some catching228 # the ready set and let's see if there's some catching
229 # up to do229 # up to do
230230
=== modified file 'ampoule/test/test_process.py'
--- ampoule/test/test_process.py 2012-04-13 03:27:08 +0000
+++ ampoule/test/test_process.py 2017-09-15 17:16:28 +0000
@@ -781,15 +781,25 @@
781 ).addCallback(lambda _: pp.stop())781 ).addCallback(lambda _: pp.stop())
782782
783 def processTimeoutTest(self, timeout):783 def processTimeoutTest(self, timeout):
784 """
785 A call with a timeout is correctly terminated, and the process pool
786 starts a new worker so that it can handle further calls.
787 """
784 pp = pool.ProcessPool(WaitingChild, min=1, max=1)788 pp = pool.ProcessPool(WaitingChild, min=1, max=1)
789 ECHO_STRING = "hello"
785 790
786 def _work(_):791 def _first(_):
787 d = pp.callRemote(First, data="ciao", _timeout=timeout)792 d = pp.callRemote(First, data="ciao", _timeout=timeout)
788 self.assertFailure(d, error.ProcessTerminated)793 self.assertFailure(d, error.ProcessTerminated)
789 return d794 return d
790795
796 def _echo(_):
797 return pp.callRemote(commands.Echo, data=ECHO_STRING
798 ).addCallback(self.assertEqual, {"response": ECHO_STRING})
799
791 return pp.start(800 return pp.start(
792 ).addCallback(_work801 ).addCallback(_first
802 ).addCallback(_echo
793 ).addCallback(lambda _: pp.stop())803 ).addCallback(lambda _: pp.stop())
794804
795 def test_processTimeout(self):805 def test_processTimeout(self):

Subscribers

People subscribed via source and target branches