| 1 | === modified file 'twisted/internet/task.py' |
|---|
| 2 | --- twisted/internet/task.py 2012-01-15 21:19:39 +0000 |
|---|
| 3 | +++ twisted/internet/task.py 2012-09-03 13:37:05 +0000 |
|---|
| 4 | @@ -638,6 +638,15 @@ |
|---|
| 5 | self._delayedCall = None |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | + def running(self): |
|---|
| 9 | + """ |
|---|
| 10 | + Check if this L{Cooperator} is currently running. |
|---|
| 11 | + |
|---|
| 12 | + @return: C{True} if the L{Cooperator} is running, C{False} otherwise. |
|---|
| 13 | + """ |
|---|
| 14 | + return (self._started and not self._stopped) |
|---|
| 15 | + |
|---|
| 16 | + |
|---|
| 17 | |
|---|
| 18 | _theCooperator = Cooperator() |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | === modified file 'twisted/test/test_cooperator.py' |
|---|
| 22 | --- twisted/test/test_cooperator.py 2011-08-13 22:57:43 +0000 |
|---|
| 23 | +++ twisted/test/test_cooperator.py 2012-09-03 13:45:38 +0000 |
|---|
| 24 | @@ -285,6 +285,23 @@ |
|---|
| 25 | self.assertEqual(coop._delayedCall, calls[0]) |
|---|
| 26 | |
|---|
| 27 | |
|---|
| 28 | + def test_running(self): |
|---|
| 29 | + """ |
|---|
| 30 | + Test if L{Cooperator.running} reports the correct status. |
|---|
| 31 | + L{Cooperator.running} should report C{False} if the L{Cooperator} |
|---|
| 32 | + has not been started or has been stopped. |
|---|
| 33 | + """ |
|---|
| 34 | + c = task.Cooperator(started=False) |
|---|
| 35 | + self.assertEqual(c.running(), False) |
|---|
| 36 | + |
|---|
| 37 | + c.start() |
|---|
| 38 | + self.assertEqual(c.running(), True) |
|---|
| 39 | + |
|---|
| 40 | + c.stop() |
|---|
| 41 | + self.assertEqual(c.running(), False) |
|---|
| 42 | + |
|---|
| 43 | + |
|---|
| 44 | + |
|---|
| 45 | |
|---|
| 46 | |
|---|
| 47 | === added file 'twisted/topfiles/5937.feature' |
|---|
| 48 | --- twisted/topfiles/5937.feature 1970-01-01 00:00:00 +0000 |
|---|
| 49 | +++ twisted/topfiles/5937.feature 2012-09-03 13:48:06 +0000 |
|---|
| 50 | @@ -0,0 +1,1 @@ |
|---|
| 51 | +Cooperator.running can be used to determin the current cooperator status. |
|---|