From: Christian Ebner <c.ebner@proxmox.com>
To: Proxmox Backup Server development discussion
<pbs-devel@lists.proxmox.com>,
Hannes Laimer <h.laimer@proxmox.com>
Subject: Re: [pbs-devel] [PATCH proxmox 1/7] rest-server: add function that returns a join handle for spawn
Date: Tue, 4 Feb 2025 15:18:17 +0100 [thread overview]
Message-ID: <a1f5e602-4e06-4736-a7a3-9277f02bc73f@proxmox.com> (raw)
In-Reply-To: <20250116064543.74619-2-h.laimer@proxmox.com>
nit inline
On 1/16/25 07:45, Hannes Laimer wrote:
> We need this handle when we want to start multiple jobs sequentially
> from a 'manage' task. With the handle we can avoid polling for the
> task status with its upid.
>
> Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
> ---
> proxmox-rest-server/src/worker_task.rs | 21 +++++++++++++++++++--
> 1 file changed, 19 insertions(+), 2 deletions(-)
>
> diff --git a/proxmox-rest-server/src/worker_task.rs b/proxmox-rest-server/src/worker_task.rs
> index beec691e..020bdb95 100644
> --- a/proxmox-rest-server/src/worker_task.rs
> +++ b/proxmox-rest-server/src/worker_task.rs
> @@ -14,6 +14,7 @@ use serde::{Deserialize, Serialize};
> use serde_json::{json, Value};
> use tokio::signal::unix::SignalKind;
> use tokio::sync::{oneshot, watch};
> +use tokio::task::JoinHandle;
> use tracing::{info, warn};
>
> use proxmox_daemon::command_socket::CommandSocket;
> @@ -942,6 +943,22 @@ impl WorkerTask {
> to_stdout: bool,
> f: F,
> ) -> Result<String, Error>
> + where
> + F: Send + 'static + FnOnce(Arc<WorkerTask>) -> T,
> + T: Send + 'static + Future<Output = Result<(), Error>>,
> + {
> + let (upid_str, _) = Self::spawn_with_handle(worker_type, worker_id, auth_id, to_stdout, f)?;
> + Ok(upid_str)
> + }
> +
nit: docstring for `spawn_with_handle` should primarily tell what it
does, only secondarily what it is used for.
Maybe something like:
```
/// Spawn a new worker task with log context like `spawn`, but return
the tasks join handle in addition to its upid.
/// Allows for a management tasks to handle multiple worker tasks.
```
> + /// Needed when a 'management' task starts multiple tasks sequentially
> + pub fn spawn_with_handle<F, T>(
> + worker_type: &str,
> + worker_id: Option<String>,
> + auth_id: String,
> + to_stdout: bool,
> + f: F,
> + ) -> Result<(String, JoinHandle<()>), Error>
> where
> F: Send + 'static + FnOnce(Arc<WorkerTask>) -> T,
> T: Send + 'static + Future<Output = Result<(), Error>>,
> @@ -950,12 +967,12 @@ impl WorkerTask {
> let upid_str = worker.upid.to_string();
> let f = f(worker.clone());
>
> - tokio::spawn(LogContext::new(logger).scope(async move {
> + let handle = tokio::spawn(LogContext::new(logger).scope(async move {
> let result = f.await;
> worker.log_result(&result);
> }));
>
> - Ok(upid_str)
> + Ok((upid_str, handle))
> }
>
> /// Create a new worker thread.
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
next prev parent reply other threads:[~2025-02-04 14:18 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-16 6:45 [pbs-devel] [PATCH proxmox/proxmox-backup 0/7] trigger sync jobs on mount Hannes Laimer
2025-01-16 6:45 ` [pbs-devel] [PATCH proxmox 1/7] rest-server: add function that returns a join handle for spawn Hannes Laimer
2025-02-04 14:18 ` Christian Ebner [this message]
2025-01-16 6:45 ` [pbs-devel] [PATCH proxmox-backup 2/7] api types: add run-on-mount flag to SyncJobConfig Hannes Laimer
2025-02-04 14:24 ` Christian Ebner
2025-02-28 8:21 ` Hannes Laimer
2025-01-16 6:45 ` [pbs-devel] [PATCH proxmox-backup 3/7] api: admin: run configured sync jobs when a datastore is mounted Hannes Laimer
2025-02-04 14:33 ` Christian Ebner
2025-02-28 8:18 ` Hannes Laimer
2025-02-28 12:13 ` Christian Ebner
2025-01-16 6:45 ` [pbs-devel] [PATCH proxmox-backup 4/7] api: admin: trigger sync jobs only on datastore mount Hannes Laimer
2025-02-04 14:34 ` Christian Ebner
2025-05-15 11:33 ` Hannes Laimer
2025-05-15 11:45 ` Christian Ebner
2025-01-16 6:45 ` [pbs-devel] [PATCH proxmox-backup 5/7] bin: manager: run uuid_mount/mount tasks on the proxy Hannes Laimer
2025-02-04 14:41 ` Christian Ebner
2025-01-16 6:45 ` [pbs-devel] [PATCH proxmox-backup 6/7] ui: add run-on-mount checkbox to SyncJob form Hannes Laimer
2025-02-04 14:46 ` Christian Ebner
2025-02-28 11:54 ` Hannes Laimer
2025-02-04 15:22 ` Christian Ebner
2025-01-16 6:45 ` [pbs-devel] [PATCH proxmox-backup 7/7] ui: add task title for triggering sync jobs Hannes Laimer
2025-02-04 14:54 ` [pbs-devel] [PATCH proxmox/proxmox-backup 0/7] trigger sync jobs on mount Christian Ebner
2025-02-28 8:22 ` Hannes Laimer
2025-05-15 12:43 ` Hannes Laimer
-- strict thread matches above, loose matches on Subject: below --
2024-12-11 10:40 [pbs-devel] [PATCH proxmox-backup " Hannes Laimer
2024-12-11 10:40 ` [pbs-devel] [PATCH proxmox 1/7] rest-server: add function that returns a join handle for spawn Hannes Laimer
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=a1f5e602-4e06-4736-a7a3-9277f02bc73f@proxmox.com \
--to=c.ebner@proxmox.com \
--cc=h.laimer@proxmox.com \
--cc=pbs-devel@lists.proxmox.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal