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
caab52ae
Commit
caab52ae
authored
Feb 07, 2014
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
While the previous work on the foon class can't be quite recycled, it's still a nice abstraction.
parent
73ca1a17
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
20 deletions
+8
-20
lib/ansible/runner/__init__.py
+4
-4
lib/ansible/runner/foon.py
+4
-16
No files found.
lib/ansible/runner/__init__.py
View file @
caab52ae
...
@@ -63,7 +63,6 @@ PROCESS_LOCKFILE = tempfile.TemporaryFile()
...
@@ -63,7 +63,6 @@ PROCESS_LOCKFILE = tempfile.TemporaryFile()
from
foon
import
Foon
from
foon
import
Foon
FOON
=
Foon
()
################################################
################################################
...
@@ -1058,11 +1057,10 @@ class Runner(object):
...
@@ -1058,11 +1057,10 @@ class Runner(object):
# *****************************************************
# *****************************************************
def
_parallel_exec
(
self
,
host
s
):
def
_parallel_exec
(
self
,
param
s
):
''' handles mulitprocessing when more than 1 fork is required '''
''' handles mulitprocessing when more than 1 fork is required '''
FOON
.
set_size
(
self
.
forks
)
return
self
.
foon
.
map
(
_executor_hook
,
params
)
return
FOON
.
map
(
_executor_hook
,
hosts
)
# *****************************************************
# *****************************************************
...
@@ -1114,6 +1112,8 @@ class Runner(object):
...
@@ -1114,6 +1112,8 @@ class Runner(object):
if
self
.
forks
==
0
or
self
.
forks
>
len
(
hosts
):
if
self
.
forks
==
0
or
self
.
forks
>
len
(
hosts
):
self
.
forks
=
len
(
hosts
)
self
.
forks
=
len
(
hosts
)
self
.
foon
=
Foon
(
self
.
forks
)
if
p
and
getattr
(
p
,
'BYPASS_HOST_LOOP'
,
None
):
if
p
and
getattr
(
p
,
'BYPASS_HOST_LOOP'
,
None
):
# Expose the current hostgroup to the bypassing plugins
# Expose the current hostgroup to the bypassing plugins
...
...
lib/ansible/runner/foon.py
View file @
caab52ae
...
@@ -99,30 +99,18 @@ class MyPool(mpool.Pool):
...
@@ -99,30 +99,18 @@ class MyPool(mpool.Pool):
class
Foon
(
object
):
class
Foon
(
object
):
def
__init__
(
self
):
def
__init__
(
self
,
size
):
self
.
set_size
(
0
)
self
.
pool
=
self
.
_make_pool
(
size
)
def
make_pool
(
self
,
processes
=
None
,
initializer
=
None
,
initargs
=
()):
def
_
make_pool
(
self
,
processes
=
None
,
initializer
=
None
,
initargs
=
()):
'''
'''
Returns a process pool object
Returns a process pool object
'''
'''
return
MyPool
(
processes
,
initializer
,
initargs
)
return
MyPool
(
processes
,
initializer
,
initargs
)
def
set_size
(
self
,
size
):
global
OLD_SIZE
global
POOL
if
size
>
OLD_SIZE
or
POOL
is
None
:
OLD_SIZE
=
size
POOL
=
self
.
make_pool
()
def
map
(
self
,
function
,
data_list
):
def
map
(
self
,
function
,
data_list
):
global
POOL
try
:
try
:
return
POOL
.
map
(
function
,
data_list
)
return
self
.
pool
.
map
(
function
,
data_list
)
except
KeyboardInterrupt
:
except
KeyboardInterrupt
:
print
"KEYBOARD INTERRUPT!"
print
"KEYBOARD INTERRUPT!"
sys
.
exit
(
1
)
sys
.
exit
(
1
)
...
...
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