Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Felix Seibert
xtreemfs_client
Commits
1b96567e
Commit
1b96567e
authored
Mar 19, 2018
by
Felix Seibert
Browse files
changing the error handling when executing lsit of processes
parent
a5d0efdf
Changes
2
Hide whitespace changes
Inline
Side-by-side
xtreemfs_client/OSDManager.py
View file @
1b96567e
...
...
@@ -233,7 +233,7 @@ class OSDManager(object):
if
self
.
debug
:
print
(
"starting execution of delete replica commands..."
)
print
(
str
(
datetime
.
datetime
.
now
()))
processes
=
div_util
.
run_commands
(
delete_replica_command_list
,
max_processes_delete_replica
)
processes
=
div_util
.
run_commands
(
delete_replica_command_list
,
max_processes_delete_replica
,
print_errors
=
False
)
# run and repeat delete commands, until they return no error
# (if an error is returned for another reason than that one would delete the last complete replica,
...
...
@@ -273,7 +273,7 @@ class OSDManager(object):
if
self
.
debug
:
print
(
"rerunning "
+
str
(
len
(
errored_deletions
))
+
" commands because replica could not be deleted..."
)
processes
=
div_util
.
run_commands
(
errored_deletions
,
max_processes_change_policy
)
processes
=
div_util
.
run_commands
(
errored_deletions
,
max_processes_change_policy
,
print_errors
=
False
)
iterations
+=
1
if
self
.
debug
:
...
...
xtreemfs_client/div_util.py
View file @
1b96567e
...
...
@@ -33,9 +33,24 @@ def command_list_to_single_string(command_list):
return
single_string
def
run_commands
(
commands
,
max_processes
=
200
):
def
print_error
(
finished_process
):
print
(
'executing process finished with error:'
)
print
(
'process: '
)
print
(
str
(
finished_process
[
0
]))
print
(
'stdout:'
)
print
(
str
(
finished_process
[
1
][
0
]))
print
(
'stderr:'
)
print
(
str
(
finished_process
[
1
][
1
]))
'''
execute list of commands in parallel, return list of executions returned with an error
'''
def
run_commands
(
commands
,
max_processes
=
200
,
print_errors
=
True
):
running_processes
=
set
()
finish
ed_processes
=
[]
error
ed_processes
=
[]
for
command
in
commands
:
started_process
=
subprocess
.
Popen
(
command
,
stderr
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
shell
=
True
)
running_processes
.
add
(
started_process
)
...
...
@@ -45,20 +60,29 @@ def run_commands(commands, max_processes=200):
for
running_process
in
running_processes
:
if
running_process
.
poll
()
is
not
None
:
difference
.
add
(
running_process
)
finished_processes
.
append
((
running_process
.
args
,
running_process
.
communicate
(),
running_process
.
returncode
))
finished_process
=
(
running_process
.
args
,
running_process
.
communicate
(),
running_process
.
returncode
)
if
finished_process
[
2
]
!=
0
:
errored_processes
.
append
(
finished_process
)
if
print_errors
:
print_error
(
finished_process
)
running_processes
=
running_processes
.
difference
(
difference
)
for
p
in
running_processes
:
p
.
wait
()
for
finished_process
in
running_processes
:
finished_processes
.
append
((
finished_process
.
args
,
finished_process
.
communicate
(),
finished_process
.
returncode
))
return
finished_processes
finished_process
=
(
finished_process
.
args
,
finished_process
.
communicate
(),
finished_process
.
returncode
)
if
finished_process
[
2
]
!=
0
:
errored_processes
.
append
(
finished_process
)
if
print_errors
:
print_error
(
finished_process
)
return
errored_processes
# return list(map(lambda proc: (proc.args, proc.communicate(), proc.returncode), all_processes))
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment