Commit 8d0425cb authored by 4ast's avatar 4ast

Merge pull request #189 from iovisor/bblanco_dev

Suppress None return when trace_pipe drops lines
parents 79553c20 2a01f7c9
...@@ -546,10 +546,11 @@ class BPF(object): ...@@ -546,10 +546,11 @@ class BPF(object):
fields (task, pid, cpu, flags, timestamp, msg) or None if no fields (task, pid, cpu, flags, timestamp, msg) or None if no
line was read (nonblocking=True) line was read (nonblocking=True)
""" """
line = BPF.trace_readline(nonblocking) while True:
if line: line = BPF.trace_readline(nonblocking)
if not line and nonblocking: return (None,) * 6
# don't print messages related to lost events # don't print messages related to lost events
if line.startswith("CPU:"): return if line.startswith("CPU:"): continue
task = line[:16].lstrip() task = line[:16].lstrip()
line = line[17:] line = line[17:]
ts_end = line.find(":") ts_end = line.find(":")
...@@ -557,7 +558,6 @@ class BPF(object): ...@@ -557,7 +558,6 @@ class BPF(object):
cpu = cpu[1:-1] cpu = cpu[1:-1]
msg = line[ts_end + 4:] msg = line[ts_end + 4:]
return (task, int(pid), int(cpu), flags, float(ts), msg) return (task, int(pid), int(cpu), flags, float(ts), msg)
return
@staticmethod @staticmethod
def trace_readline(nonblocking=False): def trace_readline(nonblocking=False):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment