Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Rafael Monnerat
erp5
Commits
bf2a09d4
Commit
bf2a09d4
authored
Nov 17, 2020
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util/testnode/ProcessManager: explicitly close file descriptors
this prevent ResourceWarnings on python3
parent
fb38562e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
19 deletions
+22
-19
erp5/util/testnode/ProcessManager.py
erp5/util/testnode/ProcessManager.py
+22
-19
No files found.
erp5/util/testnode/ProcessManager.py
View file @
bf2a09d4
...
@@ -136,8 +136,6 @@ def killCommand(pid):
...
@@ -136,8 +136,6 @@ def killCommand(pid):
class
ProcessManager
(
object
):
class
ProcessManager
(
object
):
stdin
=
open
(
os
.
devnull
)
def
__init__
(
self
,
max_timeout
=
MAX_TIMEOUT
):
def
__init__
(
self
,
max_timeout
=
MAX_TIMEOUT
):
self
.
process_pid_set
=
set
()
self
.
process_pid_set
=
set
()
signal
.
signal
(
signal
.
SIGTERM
,
self
.
sigterm_handler
)
signal
.
signal
(
signal
.
SIGTERM
,
self
.
sigterm_handler
)
...
@@ -176,23 +174,28 @@ class ProcessManager(object):
...
@@ -176,23 +174,28 @@ class ProcessManager(object):
logger
.
info
(
'subprocess_kw : %r'
,
subprocess_kw
)
logger
.
info
(
'subprocess_kw : %r'
,
subprocess_kw
)
logger
.
info
(
'$ %s'
,
command
)
logger
.
info
(
'$ %s'
,
command
)
sys
.
stdout
.
flush
()
sys
.
stdout
.
flush
()
p
=
subprocess
.
Popen
(
args
,
stdin
=
self
.
stdin
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
env
=
env
,
close_fds
=
True
,
with
open
(
os
.
devnull
)
as
stdin
:
**
subprocess_kw
)
p
=
subprocess
.
Popen
(
args
,
stdin
=
stdin
,
stdout
=
subprocess
.
PIPE
,
self
.
process_pid_set
.
add
(
p
.
pid
)
stderr
=
subprocess
.
PIPE
,
env
=
env
,
close_fds
=
True
,
timer
=
threading
.
Timer
(
self
.
max_timeout
,
timeoutExpired
,
args
=
(
p
,))
**
subprocess_kw
)
self
.
timer_set
.
add
(
timer
)
self
.
process_pid_set
.
add
(
p
.
pid
)
timer
.
start
()
timer
=
threading
.
Timer
(
self
.
max_timeout
,
timeoutExpired
,
args
=
(
p
,))
stdout
,
stderr
=
subprocess_capture
(
p
,
log_prefix
,
get_output
=
get_output
,
output_replacers
=
output_replacers
)
self
.
timer_set
.
add
(
timer
)
timer
.
cancel
()
timer
.
start
()
self
.
timer_set
.
discard
(
timer
)
stdout
,
stderr
=
subprocess_capture
(
p
,
log_prefix
,
get_output
=
get_output
,
output_replacers
=
output_replacers
)
result
=
dict
(
status_code
=
p
.
returncode
,
command
=
command
,
timer
.
cancel
()
stdout
=
stdout
,
stderr
=
stderr
)
self
.
timer_set
.
discard
(
timer
)
self
.
process_pid_set
.
discard
(
p
.
pid
)
result
=
dict
(
status_code
=
p
.
returncode
,
command
=
command
,
if
self
.
under_cancellation
:
stdout
=
stdout
,
stderr
=
stderr
)
raise
CancellationError
(
"Test Result was cancelled"
)
self
.
process_pid_set
.
discard
(
p
.
pid
)
if
raise_error_if_fail
and
p
.
returncode
:
p
.
stdout
.
close
()
raise
SubprocessError
(
result
)
p
.
stderr
.
close
()
if
self
.
under_cancellation
:
raise
CancellationError
(
"Test Result was cancelled"
)
if
raise_error_if_fail
and
p
.
returncode
:
raise
SubprocessError
(
result
)
return
result
return
result
def
getSupportedParameterList
(
self
,
program_path
):
def
getSupportedParameterList
(
self
,
program_path
):
...
...
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