【问题标题】:how to make the progame start only one process?如何让progame只启动一个进程?
【发布时间】:2017-09-10 11:11:33
【问题描述】:

我有一个 python 项目,使用 python stand lib socketserver 监听 tcp 套接字以接收数据。

我使用pyinstaller创建了一个单一的可执行文件,现在我在linux上运行二进制程序,有两个进程。

[root@localhost vmagent]# ./vmagent 10.20.248.37 e93773b6-d04a-40b2-9c57-f4ff6995309b &
[1] 19236
[root@localhost vmagent]# ps -ef|grep vmagent
root     16475 16364  0 14:09 pts/2    00:00:00 tail -30f vmagent.log
root     19236 18581  2 15:21 pts/6    00:00:00 ./vmagent 10.20.248.37 e93773b6-d04a-40b2-9c57-f4ff6995309b
root     19246 19236  8 15:21 pts/6    00:00:00 ./vmagent 10.20.248.37 e93773b6-d04a-40b2-9c57-f4ff6995309b
root     19263 18581  0 15:22 pts/6    00:00:00 grep vmagent
[root@localhost vmagent]# 

退出当前会话并重新登录后,还有两个进程。 我怎样才能使程序只有一个进程?

[root@localhost ~]# ps -ef|grep vmagent
root     16475 16364  0 14:09 pts/2    00:00:00 tail -30f vmagent.log
root     19236     1  0 15:21 ?        00:00:00 ./vmagent 10.20.248.37 e93773b6-d04a-40b2-9c57-f4ff6995309b
root     19246 19236  0 15:21 ?        00:00:00 ./vmagent 10.20.248.37 e93773b6-d04a-40b2-9c57-f4ff6995309b
root     19542 19505  0 15:34 pts/5    00:00:00 grep vmagent
[root@localhost ~]# 

【问题讨论】:

    标签: python linux pyinstaller


    【解决方案1】:

    看来这就是 pyinstaller 的工作方式。请检查这部分文档https://pythonhosted.org/PyInstaller/advanced-topics.html#the-bootstrap-process-in-detail

    所以你的二进制文件没有启动两次,只是pyinstaller使用了两个进程。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-12-04
      • 2015-03-22
      • 2015-06-25
      • 2023-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-09
      相关资源
      最近更新 更多