mirror of
https://github.com/docker/compose.git
synced 2025-07-20 20:24:30 +02:00
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 absolute_import
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from threading import Lock
|
||||||
|
|
||||||
import six
|
import six
|
||||||
from docker.errors import APIError
|
from docker.errors import APIError
|
||||||
|
|
||||||
@ -40,6 +42,30 @@ def test_parallel_execute():
|
|||||||
assert errors == {}
|
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():
|
def test_parallel_execute_with_deps():
|
||||||
log = []
|
log = []
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user