From: Donald Hunter <donald.hunter@gmail.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
Xiao Liang <shaw.leon@gmail.com>, Jiri Pirko <jiri@resnulli.us>,
donald.hunter@redhat.com
Subject: Re: [PATCH net-next v1 2/2] tools/net/ynl: add async notification handling
Date: Mon, 11 Nov 2024 11:06:18 +0000 [thread overview]
Message-ID: <m2cyj2uj11.fsf@gmail.com> (raw)
In-Reply-To: <20241109134011.560db783@kernel.org> (Jakub Kicinski's message of "Sat, 9 Nov 2024 13:40:11 -0800")
Jakub Kicinski <kuba@kernel.org> writes:
> 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
I don't follow; what are you suggesting I initialise endtime to when
duration is 0 ?
>> + 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?
This was the limit of my python knowledge TBH. I can try using python
selectors but I suspect periodic checks will still be needed to reliably
check the endtime.
>> + except KeyboardInterrupt:
>> + return
>> + if endtime and endtime < time.time():
>> + return
next prev parent reply other threads:[~2024-11-11 11:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-08 12:38 [PATCH net-next v1 0/2] tools/net/ynl: rework async notification handling Donald Hunter
2024-11-08 12:38 ` [PATCH net-next v1 1/2] Revert "tools/net/ynl: improve async notification handling" Donald Hunter
2024-11-08 12:38 ` [PATCH net-next v1 2/2] tools/net/ynl: add async notification handling Donald Hunter
2024-11-09 21:40 ` Jakub Kicinski
2024-11-11 11:06 ` Donald Hunter [this message]
2024-11-11 18:03 ` Jakub Kicinski
2024-11-12 9:16 ` Donald Hunter
2024-11-12 15:14 ` Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2cyj2uj11.fsf@gmail.com \
--to=donald.hunter@gmail.com \
--cc=davem@davemloft.net \
--cc=donald.hunter@redhat.com \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shaw.leon@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).