summaryrefslogtreecommitdiff
path: root/libpod/container_api.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-09-21 09:40:30 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-09-21 20:07:51 +0000
commit9e81f9daa4af9802088530a35a72814172430a36 (patch)
treee8ae1239d00c83f22a741662852e4dcad34fb2c4 /libpod/container_api.go
parent785e9ea1fd985713db1aa8cc6bec07805faef7a2 (diff)
downloadpodman-9e81f9daa4af9802088530a35a72814172430a36.tar.gz
podman-9e81f9daa4af9802088530a35a72814172430a36.tar.bz2
podman-9e81f9daa4af9802088530a35a72814172430a36.zip
Refactor Wait() to not require a timeout
We added a timeout for convenience, but most invocations don't care about it. Refactor it into WaitWithTimeout() and add a Wait() that doesn't require a timeout and uses the default. Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #1527 Approved by: mheon
Diffstat (limited to 'libpod/container_api.go')
-rw-r--r--libpod/container_api.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/libpod/container_api.go b/libpod/container_api.go
index 76537ebc4..fc2058de6 100644
--- a/libpod/container_api.go
+++ b/libpod/container_api.go
@@ -593,13 +593,20 @@ func (c *Container) Inspect(size bool) (*inspect.ContainerInspectData, error) {
return c.getContainerInspectData(size, driverData)
}
-// Wait blocks on a container to exit and returns its exit code
-func (c *Container) Wait(waitTimeout time.Duration) (int32, error) {
+// Wait blocks until the container exits and returns its exit code.
+func (c *Container) Wait() (int32, error) {
+ return c.WaitWithInterval(DefaultWaitInterval)
+}
+
+// WaitWithInterval blocks until the container to exit and returns its exit
+// code. The argument is the interval at which checks the container's status.
+func (c *Container) WaitWithInterval(waitTimeout time.Duration) (int32, error) {
if !c.valid {
return -1, ErrCtrRemoved
}
- err := wait.PollImmediateInfinite(waitTimeout*time.Millisecond,
+ err := wait.PollImmediateInfinite(waitTimeout,
func() (bool, error) {
+ logrus.Debugf("Checking container %s status...", c.ID())
stopped, err := c.isStopped()
if err != nil {
return false, err