mirror of
https://github.com/containers/podman-compose.git
synced 2024-11-07 16:44:10 +01:00
Merge pull request #858 from breca/asyncio_compat
Replaces asyncio timeout with bespoke timeout function
This commit is contained in:
commit
dcb6cdb55a
@ -1114,6 +1114,23 @@ def flat_deps(services, with_extends=False):
|
||||
rec_deps(services, name)
|
||||
|
||||
|
||||
async def wait_with_timeout(coro, timeout):
|
||||
"""
|
||||
Asynchronously waits for the given coroutine to complete with a timeout.
|
||||
|
||||
Args:
|
||||
coro: The coroutine to wait for.
|
||||
timeout (int or float): The maximum number of seconds to wait for.
|
||||
|
||||
Raises:
|
||||
TimeoutError: If the coroutine does not complete within the specified timeout.
|
||||
"""
|
||||
try:
|
||||
return await asyncio.wait_for(coro, timeout)
|
||||
except asyncio.TimeoutError as exc:
|
||||
raise TimeoutError from exc
|
||||
|
||||
|
||||
###################
|
||||
# podman and compose classes
|
||||
###################
|
||||
@ -1211,8 +1228,7 @@ class Podman:
|
||||
log("Sending termination signal")
|
||||
p.terminate()
|
||||
try:
|
||||
async with asyncio.timeout(10):
|
||||
exit_code = await p.wait()
|
||||
exit_code = await wait_with_timeout(p.wait(), 10)
|
||||
except TimeoutError:
|
||||
log("container did not shut down after 10 seconds, killing")
|
||||
p.kill()
|
||||
|
Loading…
Reference in New Issue
Block a user