简体   繁体   English

Pyro:是否可以将类从服务器传递到客户端,然后在客户端实例化该类的实例?

[英]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.

相关问题 Python-扩展API客户端类或传递实例 - Python - Extend an API client class or pass instance 如果 grpc-python 服务器端有 class 实例,如何让每个客户端获得他们的 state? - How to make each client get their state if there is class instance in grpc-python server side? 如何在 python 中将参数从客户端传递到服务器 - How to pass a parameter from client side to server in python 将ssh_client对象从Login类传递给MainWindow类 - Pass ssh_client object from Login class to MainWindow class 是否可以让客户端与服务器端的Recaptcha交互? - Is it possible to let the client interact with recaptcha on the server side? 是否可以从python中的字符串变量实例化一个类? - Is it possible to instantiate a class from a string variable in python? 在 Flask 中将带有 Jquery 和 JSON 的 Javascript 数组从客户端传递到服务器端 - Pass Javascript array with Jquery and JSON from client-side to server side in Flask Pyro4客户端未收到消息 - Pyro4 client not receiving message 如何使用另一个类的实例作为属性实例化一个类? - How to instantiate a class with another class' instance as attribute? 是否可以将MySQL Server与独立客户端软件一起安装? - Is it possible to install MySQL Server along with standalone client-side software?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM