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
genotoul-bioinfo
jflow
Commits
40765a17
Commit
40765a17
authored
May 05, 2015
by
Jerome Mariette
Browse files
handle NFS latences
parent
7e1e8a72
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/jflow/utils.py
View file @
40765a17
...
...
@@ -20,6 +20,7 @@ import sys
import
smtplib
import
socket
import
math
import
shutil
try
:
import
DNS
...
...
@@ -28,6 +29,27 @@ except:
DNS
=
None
class
ServerError
(
Exception
):
pass
def
robust_rmtree
(
path
,
logger
=
None
,
max_retries
=
6
):
"""Robustly tries to delete paths.
Retries several times (with increasing delays) if an OSError
occurs. If the final attempt fails, the Exception is propagated
to the caller.
"""
dt
=
1
for
i
in
range
(
max_retries
):
try
:
shutil
.
rmtree
(
path
)
return
except
OSError
:
if
logger
:
logger
.
info
(
'Unable to remove path: %s'
%
path
)
logger
.
info
(
'Retrying after %d seconds'
%
dt
)
time
.
sleep
(
dt
)
dt
*=
2
# Final attempt, pass any Exceptions up to caller.
shutil
.
rmtree
(
path
)
def
display_error_message
(
msg
):
sys
.
stderr
.
write
(
"
\033
[91mError: "
+
msg
+
"
\n\033
[0m"
)
sys
.
exit
(
1
)
...
...
src/jflow/workflow.py
View file @
40765a17
...
...
@@ -28,7 +28,6 @@ import threading
import
types
import
logging
import
datetime
import
shutil
from
logging
import
FileHandler
from
ConfigParser
import
ConfigParser
,
NoOptionError
...
...
@@ -430,7 +429,7 @@ class Workflow(threading.Thread):
def
delete
(
self
):
if
self
.
get_status
()
in
[
self
.
STATUS_COMPLETED
,
self
.
STATUS_FAILED
,
self
.
STATUS_ABORTED
]:
sh
util
.
rmtree
(
self
.
directory
)
util
s
.
robust_
rmtree
(
self
.
directory
)
@
staticmethod
def
config_parser
(
arg_lines
):
...
...
Write
Preview
Markdown
is supported
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