Skip to content

Commit

Permalink
add: warning messge to retry
Browse files Browse the repository at this point in the history
  • Loading branch information
riku179 committed Jul 12, 2023
1 parent 9125e8d commit de2363b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion actfw_core/v4l2/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import os
import select
import time
import warnings
from ctypes import *
from ctypes.util import find_library
from typing import List
Expand Down Expand Up @@ -839,7 +840,11 @@ def __init__(self, device="/dev/video0", blocking=False):
except OSError as e:
# retry 3 times when device is busy
if e.errno != errno.EBUSY or i == 2:
raise RuntimeError("open {}: {}".format(self.device, errno.errorcode[e.errno]))
raise RuntimeError(f"open {self.device}: {errno.errorcode[e.errno]}")
warnings.warn(
f"Retrying to open {self.device} after 1 second.",
RuntimeWarning,
)
time.sleep(1)

self.converter = _v4lconvert.create(self.device_fd)
Expand Down

0 comments on commit de2363b

Please sign in to comment.