Subject: Re: [PATCH net-next v1 2/2] tools/net/ynl: add async notification handling

From: Jakub Kicinski <[email-masked]>
Date: Sat, 9 Nov 2024 13:40:11 -0800

On Fri,  8 Nov 2024 12:38:16 +0000 Donald Hunter wrote:
> +    def poll_ntf(self, interval=0.1, duration=None):
> +        endtime = time.time() + duration if duration else None

could we default duration to 0 and always check endtime?
I think we can assume that time doesn't go back for simplicity

> +        while True:
> +            try:
> +                self.check_ntf()
> +                yield self.async_msg_queue.get_nowait()
> +            except queue.Empty:
> +                try:
> +                    time.sleep(interval)

Maybe select or epoll would be better that periodic checks?

> +                except KeyboardInterrupt:
> +                    return
> +            if endtime and endtime < time.time():
> +                return