-1

我一直在使用 Pyro4 构建一个私人聊天应用程序。下面是我声明 Pyro4 守护进程的代码。

import Pyro4


@Pyro4.expose
class GreetingMaker(object):
    def get_fortune(self, name):
        return "Hello, {0}. Here is your fortune message:\n" \
           "Behold the warranty -- the bold print giveth and the fine print taketh away.".format(name)



print('Instantiates Pyro4 Daemon')
daemon = Pyro4.Daemon()       
uri_str = daemon.register(GreeetingMaker)
print('Before Request Loop')
Thread(target=daemon.requestLoop()).start()
print('After Pyro4 Daemon')

我的代码无法通过 daemon.requestLoop() 。它卡在那里。由于某些原因,我希望之后的代码被执行,所以我决定对它进行多线程处理,但我的代码不起作用。请告诉我该怎么做。

4

1 回答 1

0

关于这件事,我已经敲了将近两天的头,最后我想通了。我将代码更改为:

Thread(target=daemon.requestLoop).start()
于 2018-10-19T04:55:21.773 回答