How to timeout tokio_threadpool::blocking?

Hello,

                      tokio_threadpool::blocking(|| {
                           print_message(&s, message_id); //lets assume that function can hang.
                       }).map_err(|_| panic!("the threadpool shut down"));

Above code blocks indefinitely, is there a way to timeout tokio_threadpool::blocking?

Thanks and regard

In production code it might be doing one of the three possible things:

  1. Reading data from local disk or network.
  2. Waiting on a request from another server node.
  3. Long computation, which can get stuck.