зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 4e9cd1d537cc (bug 1384062) for flake8 failures
MozReview-Commit-ID: C2AVg8g3xpV
This commit is contained in:
Родитель
452fa31f52
Коммит
cbc5805a36
|
@ -289,10 +289,7 @@ class SystemResourceMonitor(object):
|
|||
assert self._running
|
||||
assert not self._stopped
|
||||
|
||||
try:
|
||||
self._pipe.send(('terminate',))
|
||||
except Exception:
|
||||
pass
|
||||
self._pipe.send(('terminate',))
|
||||
self._running = False
|
||||
self._stopped = True
|
||||
|
||||
|
@ -304,28 +301,9 @@ class SystemResourceMonitor(object):
|
|||
# as a separate data structure. When it has finished sending
|
||||
# samples, it sends a special "done" message to indicate it
|
||||
# is finished.
|
||||
|
||||
# multiprocessing.Pipe is not actually a pipe on at least Linux. that
|
||||
# has an effect on the expected outcome of reading from it when the
|
||||
# other end of the pipe dies, leading to possibly hanging on revc()
|
||||
# below. So we must poll().
|
||||
def poll():
|
||||
try:
|
||||
return self._pipe.poll(0.1)
|
||||
except Exception as e:
|
||||
# Poll might throw an exception even though there's still
|
||||
# data to read. That happens when the underlying system call
|
||||
# returns both POLLERR and POLLIN, but python doesn't tell us
|
||||
# about it. So assume there is something to read, and we'll
|
||||
# get an exception when trying to read the data.
|
||||
return True
|
||||
while poll():
|
||||
try:
|
||||
start_time, end_time, io_diff, cpu_diff, cpu_percent, virt_mem, \
|
||||
swap_mem = self._pipe.recv()
|
||||
except Exception as e:
|
||||
# Let's assume we're done here
|
||||
start_time = 'done'
|
||||
while self._pipe.poll(1.0):
|
||||
start_time, end_time, io_diff, cpu_diff, cpu_percent, virt_mem, \
|
||||
swap_mem = self._pipe.recv()
|
||||
|
||||
# There should be nothing after the "done" message so
|
||||
# terminate.
|
||||
|
@ -347,6 +325,11 @@ class SystemResourceMonitor(object):
|
|||
if self._process.is_alive():
|
||||
self._process.terminate()
|
||||
self._process.join(10)
|
||||
else:
|
||||
# We should have received a "done" message from the
|
||||
# child indicating it shut down properly. This only
|
||||
# happens if the child shuts down cleanly.
|
||||
assert done
|
||||
|
||||
if len(self.measurements):
|
||||
self.start_time = self.measurements[0].start
|
||||
|
|
Загрузка…
Ссылка в новой задаче