* [pdm-devel] [PATCH datacenter-manager] ui: resource tree: use AsyncPool to cancel obsolete pending loads
@ 2025-04-16 11:32 Dominik Csapak
2025-04-17 15:43 ` Thomas Lamprecht
2025-04-18 7:47 ` Dominik Csapak
0 siblings, 2 replies; 5+ messages in thread
From: Dominik Csapak @ 2025-04-16 11:32 UTC (permalink / raw)
To: pdm-devel
Currently, if a new serach term is given, a new load will occur if the
INPUT_BUFFER_MS time is reached. Any old in-flight API requests are not
canceled, and might still arrive.
To prevent that, use an AsyncPool and refresh that when the search term
changes.
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
ui/src/widget/resource_tree.rs | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/ui/src/widget/resource_tree.rs b/ui/src/widget/resource_tree.rs
index feff308..4db80a8 100644
--- a/ui/src/widget/resource_tree.rs
+++ b/ui/src/widget/resource_tree.rs
@@ -18,6 +18,7 @@ use pwt::{
},
ActionIcon, Column, Container, Fa, Panel, Progress, Row, Tooltip,
},
+ AsyncPool,
};
use pwt_macros::{builder, widget};
@@ -101,6 +102,7 @@ pub struct PdmResourceTree {
_context_listener: ContextHandle<RemoteList>,
selection: Selection,
_load_timeout: Option<Timeout>,
+ async_pool: AsyncPool,
}
impl PdmResourceTree {}
@@ -131,6 +133,7 @@ impl Component for PdmResourceTree {
_context_listener,
selection,
_load_timeout: None,
+ async_pool: AsyncPool::new(),
}
}
@@ -140,9 +143,10 @@ impl Component for PdmResourceTree {
let props = ctx.props();
let link = ctx.link().clone();
let search_term = props.search_term.clone();
+ let async_pool = self.async_pool.clone();
if props.search_only && !search_term.is_empty() {
self._load_timeout = Some(Timeout::new(INPUT_BUFFER_MS, move || {
- link.send_future(async move {
+ async_pool.send_future(link, async move {
Msg::LoadResult(load_resources(search_term).await)
});
}));
@@ -200,6 +204,8 @@ impl Component for PdmResourceTree {
let props = ctx.props();
if props.search_term != old_props.search_term {
if !props.search_only || !props.search_term.is_empty() {
+ // cancel old pending loads
+ self.async_pool = AsyncPool::new();
ctx.link().clone().send_message(Msg::Load);
} else if props.search_term.is_empty() {
// clear grid
--
2.39.5
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [pdm-devel] [PATCH datacenter-manager] ui: resource tree: use AsyncPool to cancel obsolete pending loads
2025-04-16 11:32 [pdm-devel] [PATCH datacenter-manager] ui: resource tree: use AsyncPool to cancel obsolete pending loads Dominik Csapak
@ 2025-04-17 15:43 ` Thomas Lamprecht
2025-04-18 6:10 ` Dominik Csapak
2025-04-18 7:47 ` Dominik Csapak
1 sibling, 1 reply; 5+ messages in thread
From: Thomas Lamprecht @ 2025-04-17 15:43 UTC (permalink / raw)
To: Proxmox Datacenter Manager development discussion, Dominik Csapak
Am 16.04.25 um 13:32 schrieb Dominik Csapak:
> Currently, if a new serach term is given, a new load will occur if the
> INPUT_BUFFER_MS time is reached. Any old in-flight API requests are not
> canceled, and might still arrive.
>
> To prevent that, use an AsyncPool and refresh that when the search term
> changes.
I forgot a few details here, but would it be possible to provide a wrapper
component for such things? I.e. fields where editing will trigger an API
request. As to me, it feels like this is an easy error to make for any
such fields, especially as it normally won't be noticed if tested locally
with <1ms network latency and the often relatively smaller (test) setups,
where the code querying the data in the backend needs only a few ms too.
But in any way not something that needs to delay applying this patch.
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [pdm-devel] [PATCH datacenter-manager] ui: resource tree: use AsyncPool to cancel obsolete pending loads
2025-04-17 15:43 ` Thomas Lamprecht
@ 2025-04-18 6:10 ` Dominik Csapak
2025-04-18 7:29 ` Dominik Csapak
0 siblings, 1 reply; 5+ messages in thread
From: Dominik Csapak @ 2025-04-18 6:10 UTC (permalink / raw)
To: Thomas Lamprecht, Proxmox Datacenter Manager development discussion
On 4/17/25 17:43, Thomas Lamprecht wrote:
> Am 16.04.25 um 13:32 schrieb Dominik Csapak:
>> Currently, if a new serach term is given, a new load will occur if the
>> INPUT_BUFFER_MS time is reached. Any old in-flight API requests are not
>> canceled, and might still arrive.
>>
>> To prevent that, use an AsyncPool and refresh that when the search term
>> changes.
>
> I forgot a few details here, but would it be possible to provide a wrapper
> component for such things? I.e. fields where editing will trigger an API
> request. As to me, it feels like this is an easy error to make for any
> such fields, especially as it normally won't be noticed if tested locally
> with <1ms network latency and the often relatively smaller (test) setups,
> where the code querying the data in the backend needs only a few ms too.
mhmm, the AsyncPool is already the helper wrapper we should use for this,
we just have to apply it consistently.
The only special thing we do here is to replace the asyncpool with a new
one in the 'changed' method.
maybe a method for the async pool that takes additionally an id and
replaces the old future with the new one in case there is already
an in flight future with the same name?
(we use the asyncpool to handle multiple futures, so we'd need
to identify them)
>
> But in any way not something that needs to delay applying this patch.
>
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [pdm-devel] [PATCH datacenter-manager] ui: resource tree: use AsyncPool to cancel obsolete pending loads
2025-04-18 6:10 ` Dominik Csapak
@ 2025-04-18 7:29 ` Dominik Csapak
0 siblings, 0 replies; 5+ messages in thread
From: Dominik Csapak @ 2025-04-18 7:29 UTC (permalink / raw)
To: Thomas Lamprecht, Proxmox Datacenter Manager development discussion
after looking again, what we want here is not the asyncpool but the
asyncabortguard (totally forgot this is a thing)
with that it should be automatic, since when we overwrite the old one
it'll get dropped + aborted
i'll send a v2
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [pdm-devel] [PATCH datacenter-manager] ui: resource tree: use AsyncPool to cancel obsolete pending loads
2025-04-16 11:32 [pdm-devel] [PATCH datacenter-manager] ui: resource tree: use AsyncPool to cancel obsolete pending loads Dominik Csapak
2025-04-17 15:43 ` Thomas Lamprecht
@ 2025-04-18 7:47 ` Dominik Csapak
1 sibling, 0 replies; 5+ messages in thread
From: Dominik Csapak @ 2025-04-18 7:47 UTC (permalink / raw)
To: pdm-devel
superseded by v2:
https://lore.proxmox.com/pdm-devel/20250418074647.1057147-1-d.csapak@proxmox.com/
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-04-18 7:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-16 11:32 [pdm-devel] [PATCH datacenter-manager] ui: resource tree: use AsyncPool to cancel obsolete pending loads Dominik Csapak
2025-04-17 15:43 ` Thomas Lamprecht
2025-04-18 6:10 ` Dominik Csapak
2025-04-18 7:29 ` Dominik Csapak
2025-04-18 7:47 ` Dominik Csapak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal