mirror of https://github.com/docker/compose.git
Test for parallel_execute with limit
Signed-off-by: Evan Shaw <evan@vendhq.com>
This commit is contained in:
parent
b4b221f6a3
commit
e29e3f8da4
|
@ -1,6 +1,8 @@
|
|||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from threading import Lock
|
||||
|
||||
import six
|
||||
from docker.errors import APIError
|
||||
|
||||
|
@ -40,6 +42,30 @@ def test_parallel_execute():
|
|||
assert errors == {}
|
||||
|
||||
|
||||
def test_parallel_execute_with_limit():
|
||||
limit = 1
|
||||
tasks = 20
|
||||
lock = Lock()
|
||||
|
||||
def f(obj):
|
||||
locked = lock.acquire(False)
|
||||
# we should always get the lock because we're the only thread running
|
||||
assert locked
|
||||
lock.release()
|
||||
return None
|
||||
|
||||
results, errors = parallel_execute(
|
||||
objects=list(range(tasks)),
|
||||
func=f,
|
||||
get_name=six.text_type,
|
||||
msg="Testing",
|
||||
limit=limit,
|
||||
)
|
||||
|
||||
assert results == tasks*[None]
|
||||
assert errors == {}
|
||||
|
||||
|
||||
def test_parallel_execute_with_deps():
|
||||
log = []
|
||||
|
||||
|
|
Loading…
Reference in New Issue