使用Pyro实例化一个类

问题描述 投票:0回答:1

我有一个有构造函数的类:

@Pyro.expose
class MyClass:

    def __init__(self, opt=10):
        self.opt = opt

    def get(self):
        return self.opt

这个类是用Pyro公开的,但我只能调用方法“get”,因此opt的值总是10,因为我不能用另一个值实例化该类。

你对如何解决这个问题有任何想法吗?

谢谢你们!

python-3.x pyro pyro4
1个回答
0
投票

您可以使用其行为装饰器控制Pyro创建服务器类实例的方式。见https://pyro4.readthedocs.io/en/stable/servercode.html#controlling-instance-modes-and-instance-creation

听起来你想使用它的instance_creator参数。

© www.soinside.com 2019 - 2024. All rights reserved.