Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
strudel2_backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hpc-team
strudel2_backend
Commits
a0db555e
Commit
a0db555e
authored
6 years ago
by
Chris Hines
Browse files
Options
Downloads
Patches
Plain Diff
put a timeout on executing things via ssh
parent
ad1f596a
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
tes/sshwrapper/__init__.py
+9
-3
9 additions, 3 deletions
tes/sshwrapper/__init__.py
with
9 additions
and
3 deletions
tes/sshwrapper/__init__.py
+
9
−
3
View file @
a0db555e
...
@@ -3,6 +3,7 @@ This module handles SSH Connections
...
@@ -3,6 +3,7 @@ This module handles SSH Connections
"""
"""
import
subprocess
import
subprocess
TIMEOUT
=
10
class
SshAgentException
(
Exception
):
class
SshAgentException
(
Exception
):
"""
"""
Raised if an SSH Agent isn
'
t running (Normally the SPA client should invoke the agent
Raised if an SSH Agent isn
'
t running (Normally the SPA client should invoke the agent
...
@@ -270,10 +271,15 @@ class Ssh:
...
@@ -270,10 +271,15 @@ class Ssh:
'
-p
'
,
sshport
,
'
-l
'
,
user
,
host
,
cmd
],
'
-p
'
,
sshport
,
'
-l
'
,
user
,
host
,
cmd
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
stdin
=
subprocess
.
PIPE
,
env
=
env
)
stdin
=
subprocess
.
PIPE
,
env
=
env
)
if
stdin
is
not
None
:
try
:
(
stdout
,
stderr
)
=
exec_p
.
communicate
(
stdin
.
encode
())
if
stdin
is
not
None
:
else
:
(
stdout
,
stderr
)
=
exec_p
.
communicate
(
stdin
.
encode
(),
timeout
=
TIMEOUT
)
else
:
(
stdout
,
stderr
)
=
exec_p
.
communicate
(
timeout
=
TIMEOUT
)
except
subprocess
.
TimeoutExpired
:
exec_p
.
kill
()
(
stdout
,
stderr
)
=
exec_p
.
communicate
()
(
stdout
,
stderr
)
=
exec_p
.
communicate
()
return
{
'
stdout
'
:
stdout
,
'
stderr
'
:
stderr
}
return
{
'
stdout
'
:
stdout
,
'
stderr
'
:
stderr
}
@staticmethod
@staticmethod
...
...
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