Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
satella
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public
satella
Commits
dbe43435
Commit
dbe43435
authored
5 years ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
resolve a #todo
parent
5afcd743
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
satella/processes.py
+5
-4
5 additions, 4 deletions
satella/processes.py
with
5 additions
and
4 deletions
satella/processes.py
+
5
−
4
View file @
dbe43435
...
@@ -10,8 +10,10 @@ logger = logging.getLogger(__name__)
...
@@ -10,8 +10,10 @@ logger = logging.getLogger(__name__)
def
read_nowait
(
process
:
subprocess
.
Popen
,
output_list
:
tp
.
List
[
str
]):
def
read_nowait
(
process
:
subprocess
.
Popen
,
output_list
:
tp
.
List
[
str
]):
try
:
try
:
while
process
.
stdout
.
readable
():
while
process
.
poll
()
is
None
:
line
=
process
.
stdout
.
readline
()
line
=
process
.
stdout
.
read
(
2048
)
if
line
==
''
:
break
output_list
.
append
(
line
)
output_list
.
append
(
line
)
except
(
IOError
,
OSError
):
except
(
IOError
,
OSError
):
pass
pass
...
@@ -29,8 +31,6 @@ def call_and_return_stdout(args: tp.Union[str, tp.List[str]],
...
@@ -29,8 +31,6 @@ def call_and_return_stdout(args: tp.Union[str, tp.List[str]],
A bytes object will be returned if encoding is not defined, else stdout will be decoded
A bytes object will be returned if encoding is not defined, else stdout will be decoded
according to specified encoding.
according to specified encoding.
#todo every usage of this call will spawn a daemonic thread, pending a fix
:param args: arguments to run the program with. If passed a string, it will be split on space.
:param args: arguments to run the program with. If passed a string, it will be split on space.
:param timeout: amount of seconds to wait for the process result. If process does not complete
:param timeout: amount of seconds to wait for the process result. If process does not complete
within this time, it will be sent a SIGKILL
within this time, it will be sent a SIGKILL
...
@@ -54,6 +54,7 @@ def call_and_return_stdout(args: tp.Union[str, tp.List[str]],
...
@@ -54,6 +54,7 @@ def call_and_return_stdout(args: tp.Union[str, tp.List[str]],
except
subprocess
.
TimeoutExpired
:
except
subprocess
.
TimeoutExpired
:
proc
.
kill
()
proc
.
kill
()
proc
.
wait
()
proc
.
wait
()
reader_thread
.
join
()
if
proc
.
returncode
!=
expected_return_code
:
if
proc
.
returncode
!=
expected_return_code
:
raise
ProcessFailed
(
proc
.
returncode
)
raise
ProcessFailed
(
proc
.
returncode
)
...
...
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