processes.Process was raising DeadProcess for subprocesses that simply didn't emit any output.
This commit is contained in:
3
AUTHORS
3
AUTHORS
@@ -23,10 +23,11 @@ Linden Lab Contributors
|
||||
|
||||
Thanks To
|
||||
---------
|
||||
* Chuck Thier, reporting a bug in processes.py
|
||||
* Brantley Harris, reporting bug #4
|
||||
* Taso Du Val, reproing an exception squelching bug, saving children's lives ;-)
|
||||
* R. Tyler Ballance, bug report on tpool on Windows, help with improving corolocal module
|
||||
* Sergey Shepelev, PEP 8 police :-)
|
||||
* Sergey Shepelev, PEP 8 police :-), reporting bug #5
|
||||
* Luci Stanescu, for reporting twisted hub bug
|
||||
* Marcus Cavanaugh, for test case code that has been incredibly useful in tracking down bugs
|
||||
* Brian Brunswick, for many helpful questions and suggestions on the mailing list
|
||||
|
||||
3
NEWS
3
NEWS
@@ -13,8 +13,7 @@
|
||||
* Added support for logging x-forwarded-for header in wsgi.
|
||||
* api.tcp_server is now deprecated, will be removed in a future release.
|
||||
* Added instructions on how to generate coverage reports to the documentation.
|
||||
* Bug fixes in: wsgi.py, twistedr.py, poll.py, greenio.py, util.py, select.py
|
||||
|
||||
* Bug fixes in: wsgi.py, twistedr.py, poll.py, greenio.py, util.py, select.py, processes.py
|
||||
|
||||
0.9.0
|
||||
=====
|
||||
|
||||
@@ -76,6 +76,7 @@ class Process(object):
|
||||
self.send = self.child_stdin.write
|
||||
self.recv = self.child_stdout_stderr.read
|
||||
self.readline = self.child_stdout_stderr.readline
|
||||
self._read_first_result = False
|
||||
|
||||
def wait(self):
|
||||
return cooperative_wait(self.popen4)
|
||||
@@ -94,11 +95,17 @@ class Process(object):
|
||||
raise RuntimeError("Unknown mode", mode)
|
||||
|
||||
def read(self, amount=None):
|
||||
"""Reads from the stdout and stderr of the child process.
|
||||
The first call to read() will return a string; subsequent
|
||||
calls may raise a DeadProcess when EOF occurs on the pipe.
|
||||
"""
|
||||
result = self.child_stdout_stderr.read(amount)
|
||||
if result == '':
|
||||
if result == '' and self._read_first_result:
|
||||
# This process is dead.
|
||||
self.dead_callback()
|
||||
raise DeadProcess
|
||||
else:
|
||||
self._read_first_result = True
|
||||
return result
|
||||
|
||||
def write(self, stuff):
|
||||
|
||||
@@ -24,7 +24,12 @@ class TestEchoPool(TestCase):
|
||||
self.assertRaises(processes.DeadProcess, proc.read)
|
||||
finally:
|
||||
self.pool.put(proc)
|
||||
|
||||
|
||||
def test_empty_echo(self):
|
||||
p = processes.Process('echo', ['-n'])
|
||||
self.assertEquals('', p.read())
|
||||
self.assertRaises(processes.DeadProcess, p.read)
|
||||
|
||||
|
||||
class TestCatPool(TestCase):
|
||||
def setUp(self):
|
||||
|
||||
Reference in New Issue
Block a user