[英]Pyro: Is it possible to pass a class from a server to a client and then instantiate an instance of that class on the client side?
High level overview: I have a server.py
file and a class WorkTask.py
that has some function execute
in it, both stored on my server. 高级别概述:我有一个
server.py
文件和一个其中execute
一些功能的WorkTask.py
类,它们都存储在服务器上。 I also have a client.py
that runs remotely and connects to the server using pyro. 我也有一个
client.py
,它可以远程运行并使用pyro连接到服务器。 Is there anyway that I can pass the WorkTask
class from the server to the client and then run the WorkTask.execute()
function on the client side? 无论如何,我可以将
WorkTask
类从服务器传递到客户端,然后在客户端运行WorkTask.execute()
函数吗?
Only if you have a copy of WorkTask.py on the client already, and are using the pickle serializer. 仅当您已经在客户端上具有WorkTask.py副本并且正在使用pickle序列化程序时。
You could also perhaps look at Pyro4.utils.flame.createModule(). 您也许还可以查看Pyro4.utils.flame.createModule()。 See https://pythonhosted.org/Pyro4/flame.html
参见https://pythonhosted.org/Pyro4/flame.html
It's a big security risk though because using pickle allows for arbitrary code execution if you connect to an untrusted remote party. 但是,这存在很大的安全风险,因为如果您连接到不受信任的远程方,则使用pickle可以执行任意代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.