name remaining blocking tasks

This commit is contained in:
Simon Laux
2024-10-10 15:11:46 +02:00
parent 95aaaee43c
commit 3ff271ba93
3 changed files with 26 additions and 28 deletions

View File

@@ -353,9 +353,8 @@ async fn start(args: Vec<String>) -> Result<(), Error> {
match readline {
Ok(line) => {
// TODO: ignore "set mail_pw"
rl.add_history_entry(line.as_str())?;
let should_continue = Handle::current().block_on(async {
let should_continue = spawn_named_blocking_task!("repl:handle_cmd", async {
match handle_cmd(line.trim(), ctx.clone(), &mut selected_chat).await {
Ok(ExitResult::Continue) => true,
Ok(ExitResult::Exit) => {

View File

@@ -12,13 +12,13 @@ use pgp::composed::Deserializable;
pub use pgp::composed::{SignedPublicKey, SignedSecretKey};
use pgp::ser::Serialize;
use pgp::types::{KeyTrait, SecretKeyTrait};
use tokio::runtime::Handle;
use crate::config::Config;
use crate::constants::KeyGenType;
use crate::context::Context;
use crate::log::LogExt;
use crate::pgp::KeyPair;
use crate::spawn_named_blocking_task;
use crate::tools::{self, time_elapsed};
/// Convenience trait for working with keys.
@@ -251,9 +251,10 @@ async fn generate_keypair(context: &Context) -> Result<KeyPair> {
let keytype = KeyGenType::from_i32(context.get_config_int(Config::KeyGenType).await?)
.unwrap_or_default();
info!(context, "Generating keypair with type {}", keytype);
// TODO? add it here as well?
let keypair = Handle::current()
.spawn_blocking(move || crate::pgp::create_keypair(addr, keytype))
let keypair =
spawn_named_blocking_task!("generate_keypair", move || crate::pgp::create_keypair(
addr, keytype
))
.await??;
store_self_keypair(context, &keypair, KeyPairUse::Default).await?;

View File

@@ -251,9 +251,7 @@ pub async fn pk_encrypt(
) -> Result<String> {
let lit_msg = Message::new_literal_bytes("", plain);
// TODO? label this
Handle::current()
.spawn_blocking(move || {
spawn_named_blocking_task("pk_encrypt", move || {
let pkeys: Vec<SignedPublicKeyOrSubkey> = public_keys_for_encryption
.iter()
.filter_map(select_pk_for_encryption)