mirror of
https://github.com/ansible/awx.git
synced 2024-10-31 23:51:09 +03:00
Merge pull request #2060 from AlanCoding/one_less_counter
Get rid of duplicate counter variable
This commit is contained in:
commit
d1bc9758db
@ -1024,7 +1024,7 @@ class BaseTask(Task):
|
||||
if stdout_handle:
|
||||
stdout_handle.flush()
|
||||
stdout_handle.close()
|
||||
event_ct = getattr(stdout_handle, '_event_ct', 0)
|
||||
event_ct = getattr(stdout_handle, '_counter', 0)
|
||||
logger.info('%s finished running, producing %s events.',
|
||||
instance.log_format, event_ct)
|
||||
except Exception:
|
||||
|
@ -448,7 +448,7 @@ class TestGenericRun(TestJobExecution):
|
||||
def test_event_count(self):
|
||||
with mock.patch.object(self.task, 'get_stdout_handle') as mock_stdout:
|
||||
handle = OutputEventFilter(lambda event_data: None)
|
||||
handle._event_ct = 334
|
||||
handle._counter = 334
|
||||
mock_stdout.return_value = handle
|
||||
self.task.run(self.pk)
|
||||
|
||||
|
@ -945,8 +945,7 @@ class OutputEventFilter(object):
|
||||
|
||||
def __init__(self, event_callback):
|
||||
self._event_callback = event_callback
|
||||
self._event_ct = 0
|
||||
self._counter = 1
|
||||
self._counter = 0
|
||||
self._start_line = 0
|
||||
self._buffer = StringIO()
|
||||
self._last_chunk = ''
|
||||
@ -1005,8 +1004,8 @@ class OutputEventFilter(object):
|
||||
stdout_chunks = []
|
||||
|
||||
for stdout_chunk in stdout_chunks:
|
||||
event_data['counter'] = self._counter
|
||||
self._counter += 1
|
||||
event_data['counter'] = self._counter
|
||||
event_data['stdout'] = stdout_chunk[:-2] if len(stdout_chunk) > 2 else ""
|
||||
n_lines = stdout_chunk.count('\n')
|
||||
event_data['start_line'] = self._start_line
|
||||
@ -1014,7 +1013,6 @@ class OutputEventFilter(object):
|
||||
self._start_line += n_lines
|
||||
if self._event_callback:
|
||||
self._event_callback(event_data)
|
||||
self._event_ct += 1
|
||||
|
||||
if next_event_data.get('uuid', None):
|
||||
self._current_event_data = next_event_data
|
||||
|
Loading…
Reference in New Issue
Block a user