Python程序停止但PID仍处于活动状态

时间:2017-02-25 15:06:02

标签: python exit pid python-asyncio autobahn

我的程序在大约6小时后停止工作,但PID仍处于活动状态。当我使用single_process模块然后尝试再次启动程序时,还告诉我终端输出:

There is an instance of programm.py running. Quit

我的程序代码退出简单,只是从聊天室读取输出,但我不知道为什么它会在6小时后停止工作。有人可以帮忙吗?:

from autobahn.asyncio.wamp import ApplicationSession
from autobahn.asyncio.wamp import ApplicationRunner
from asyncio import coroutine
from datetime import datetime
from single_process import single_process


class PoloniexComponent(ApplicationSession):

    def onConnect(self):
        self.join(self.config.realm)

    @coroutine
    def onJoin(self, details):
        def onTrollbox(*args):
            print("type: ", args[0])
            print("msg_number: ", args[1])
            print("user_name: ", args[2])
            print("message: ", args[3])
            print("reputation: ", args[4])
            print(datetime.utcnow())
        try:
            yield from self.subscribe(onTrollbox, 'trollbox')
        except Exception as e:
            print("Could not subscribe to topic:", e)


@single_process
def main():
    runner = ApplicationRunner("wss://api.poloniex.com", "realm1")
    runner.run(PoloniexComponent)


if __name__ == "__main__":
    main()

0 个答案:

没有答案