一、rpc适用于分布式处理,其例子如下:
1、服务端代码
# -*- coding: utf-8 -*-
"""rpc server module."""
import rpyc
from rpyc.utils.server import ThreadedServer
import time
import cv2
import numpy as np
import _thread
import base64
import json
img_list=[]
hbs_list=[]
# from cv2 import cv
class RpcServer(rpyc.Service):
def on_connect(self, conn):
# code that runs when a connection is created
# (to init the service, if needed)
print(conn)
pass
def on_disconnect(self, conn):
# code that runs after the connection has already closed
# (to finalize the service, if needed)
pass
def exposed_show_img(self,img): # this is an exposed method
# print(img)