Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
718e2930
Commit
718e2930
authored
Mar 03, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
async module now forks
parent
45c40524
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
6 deletions
+26
-6
library/async_wrapper
+26
-6
No files found.
library/async_wrapper
View file @
718e2930
...
...
@@ -36,9 +36,11 @@ if len(sys.argv) < 3:
})
sys
.
exit
(
1
)
print
sys
.
argv
jid
=
sys
.
argv
[
1
]
wrapped_module
=
sys
.
argv
[
2
]
time_limit
=
sys
.
argv
[
3
]
time_limit
=
sys
.
argv
[
2
]
wrapped_module
=
sys
.
argv
[
3
]
args
=
sys
.
argv
[
4
:]
cmd
=
"
%
s
%
s"
%
(
wrapped_module
,
" "
.
join
(
args
))
...
...
@@ -73,11 +75,13 @@ def _run_command(wrapped_cmd, jid, log_path):
except
(
OSError
,
IOError
),
e
:
result
=
{
"failed"
:
1
,
"cmd"
:
wrapped_cmd
,
"msg"
:
str
(
e
),
}
except
:
result
=
{
"failed"
:
1
,
"cmd"
:
wrapped_cmd
,
"msg"
:
traceback
.
format_exc
()
}
...
...
@@ -86,12 +90,28 @@ def _run_command(wrapped_cmd, jid, log_path):
logfile
.
write
(
json
.
dumps
(
result
))
logfile
.
close
()
# TEMPORARY:
print
json
.
dumps
(
result
)
# TODO: daemonize this with time limits
# TODO: might be nice to keep timing data, eventually...
_run_command
(
cmd
,
jid
,
log_path
)
pid
=
os
.
fork
()
if
pid
==
0
:
print
json
.
dumps
({
"started"
:
1
,
"ansible_job_id"
:
jid
})
sys
.
exit
(
0
)
else
:
# FIXME: need to implement time limits
# probably something easy like:
#
# sub_pid = os.fork()
# if sub_pid == 0:
# run command
# else
# check status
# sleep 1 second
# kill if greater than timelimit
_run_command
(
cmd
,
jid
,
log_path
)
sys
.
exit
(
0
)
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