【问题标题】:Rust Actix: Get SystemRunner for System::current()Rust Actix:为 System::current() 获取 SystemRunner
【发布时间】:2019-05-20 00:24:35
【问题描述】:

有没有办法从当前的System(我从System::current() 获得)获取SystemRunner 对象。我无法通过文档找到一种方法,但我觉得它应该存在。

我有一个端点,用户可能会调用使用block_on 的方法,该方法需要SystemRunner 的实例才能运行。我想避免再次调用System::new("actix"),而只使用当前正在运行的System。

【问题讨论】:

    标签: rust-actix


    【解决方案1】:

    没有办法block_on运行系统。

    对于测试,您可以在actix-web 的测试工具中使用block_on 助手: https://github.com/actix/actix-web/blob/master/src/test.rs#L60 创建本地运行时并在当前线程上阻塞。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-11
      • 2021-08-20
      • 2021-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-21
      • 1970-01-01
      相关资源
      最近更新 更多