脚本如何将自己置于后台?

时间:2015-12-12 09:16:46

标签: python-3.x

注意:虽然在MS Windows和Linux上运行的解决方案都很棒,但我对使用它在Linux中工作特别感兴趣(因此只支持Linux的解决方案)。

我知道可以按照脚本

的顺序来操作操作系统
$ python3 myscript.py &

但我有一个案例

(...)
if __name__ == "__main__":
    # some long-lasting (= infinity) threads are started here
    (...)
    # here are some blocking checks which make sure that the threads were fully started
    (...)
    # now that the threads are fully initialized, I would normally perform a .join(), which will leave the script waiting for the threads to finish (which they will not)

我希望代替(或另外)将阻塞的.join(),将脚本移动到后台,以便它可以退出到随后启动其他命令的shell。这些命令取决于上面脚本的正确启动(这是"阻止检查")的原因。

执行此类任务的机制有哪些?

0 个答案:

没有答案
相关问题