Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review 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
RadioObservatory
LOFAR
Commits
1183a660
Commit
1183a660
authored
8 years ago
by
Jan David Mol
Browse files
Options
Downloads
Patches
Plain Diff
Task #9678: Use select.poll instead of select.select to support fd > 1024
parent
13107463
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
CEP/Pipeline/framework/lofarpipe/support/subprocessgroup.py
+14
-12
14 additions, 12 deletions
CEP/Pipeline/framework/lofarpipe/support/subprocessgroup.py
CEP/Pipeline/test/support/subprocessgroup_test.py
+11
-1
11 additions, 1 deletion
CEP/Pipeline/test/support/subprocessgroup_test.py
with
25 additions
and
13 deletions
CEP/Pipeline/framework/lofarpipe/support/subprocessgroup.py
+
14
−
12
View file @
1183a660
...
...
@@ -96,12 +96,11 @@ class SubProcess(object):
def
fds
(
self
):
return
self
.
output_streams
.
values
()
def
read
(
self
,
fds
):
for
fd
in
fds
:
if
fd
==
self
.
process
.
stdout
:
self
.
_addoutput
(
self
.
STDOUT
,
fd
.
read
(
4096
))
if
fd
==
self
.
process
.
stderr
:
self
.
_addoutput
(
self
.
STDERR
,
fd
.
read
(
4096
))
def
read
(
self
,
fileno
):
if
fileno
==
self
.
process
.
stdout
.
fileno
():
self
.
_addoutput
(
self
.
STDOUT
,
self
.
process
.
stdout
.
read
(
4096
))
if
fileno
==
self
.
process
.
stderr
.
fileno
():
self
.
_addoutput
(
self
.
STDERR
,
self
.
process
.
stderr
.
read
(
4096
))
def
_addoutput
(
self
,
stdtype
,
output
,
flush
=
False
):
buf
=
self
.
output_buffers
[
stdtype
]
+
output
...
...
@@ -215,17 +214,20 @@ class SubProcessGroup(object):
for
process
in
processes
:
process
.
kill
()
# collect fds we need to poll
fds
=
[]
# collect fds we need to poll -- we need select.poll to support fd > 1024
poller
=
select
.
poll
()
fd_lookup
=
{}
for
process
in
processes
:
fds
.
extend
(
process
.
fds
())
for
fd
in
process
.
fds
():
poller
.
register
(
fd
,
select
.
POLLIN
)
fd_lookup
[
fd
.
fileno
()]
=
process
# poll for data
rlist
,
_
,
_
=
select
.
select
(
fds
,
[],
[],
self
.
polling_interval
)
events
=
poller
.
poll
(
self
.
polling_interval
)
# let processed read their data
for
process
in
processe
s
:
process
.
read
(
rlist
)
for
(
fileno
,
_
)
in
event
s
:
fd_lookup
[
fileno
].
read
(
fileno
)
# check all the running processes for completion
for
process
in
self
.
process_group
:
...
...
This diff is collapsed.
Click to expand it.
CEP/Pipeline/test/support/subprocessgroup_test.py
+
11
−
1
View file @
1183a660
...
...
@@ -59,6 +59,16 @@ class SubProcessGroupTest(unittest.TestCase):
self
.
assertTrue
((
end_time
-
start_time
)
>
3
)
def
test_fd_bigger_than_1024
(
self
):
process_group
=
SubProcessGroup
(
polling_interval
=
1
,
max_concurrent_processes
=
1000
)
cmd
=
"
sleep 2
"
for
idx
in
range
(
513
):
# each process uses 2 fds, so we only need 513 processes to ensure fds > 1024
process_group
.
run
(
cmd
)
process_group
.
wait_for_finish
()
def
test_start_without_jobs
(
self
):
process_group
=
SubProcessGroup
(
polling_interval
=
1
)
...
...
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