Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mininet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Olaf Bergmann
mininet
Commits
31fe4f1b
Commit
31fe4f1b
authored
12 years ago
by
Bob Lantz
Browse files
Options
Downloads
Patches
Plain Diff
Fix pmonitor() to not return blank lines on EOF
fixes #109 (hopefully)
parent
dcb3036b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mininet/util.py
+14
-17
14 additions, 17 deletions
mininet/util.py
with
14 additions
and
17 deletions
mininet/util.py
+
14
−
17
View file @
31fe4f1b
...
...
@@ -4,7 +4,7 @@
from
time
import
sleep
from
resource
import
setrlimit
,
RLIMIT_NPROC
,
RLIMIT_NOFILE
from
select
import
poll
,
POLLIN
from
select
import
poll
,
POLLIN
,
POLLHUP
from
subprocess
import
call
,
check_call
,
Popen
,
PIPE
,
STDOUT
import
re
from
fcntl
import
fcntl
,
F_GETFL
,
F_SETFL
...
...
@@ -326,27 +326,24 @@ def pmonitor(popens, timeoutms=500, readline=True,
# Use non-blocking reads
flags
=
fcntl
(
fd
,
F_GETFL
)
fcntl
(
fd
,
F_SETFL
,
flags
|
O_NONBLOCK
)
while
True
:
while
popens
:
fds
=
poller
.
poll
(
timeoutms
)
if
fds
:
for
fd
,
_
event
in
fds
:
for
fd
,
event
in
fds
:
host
=
fdToHost
[
fd
]
popen
=
popens
[
host
]
if
readline
:
# Attempt to read a line of output
# This blocks until we receive a newline!
line
=
popen
.
stdout
.
readline
()
else
:
line
=
popen
.
stdout
.
read
(
readmax
)
yield
host
,
line
if
event
&
POLLIN
:
if
readline
:
# Attempt to read a line of output
# This blocks until we receive a newline!
line
=
popen
.
stdout
.
readline
()
else
:
line
=
popen
.
stdout
.
read
(
readmax
)
yield
host
,
line
# Check for EOF
if
not
line
:
popen
.
poll
()
if
popen
.
returncode
is
not
None
:
poller
.
unregister
(
fd
)
del
popens
[
host
]
if
not
popens
:
return
elif
event
&
POLLHUP
:
poller
.
unregister
(
fd
)
del
popens
[
host
]
else
:
yield
None
,
''
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment