Hi, your example suggests that the program hellow.bat is execute on the server.
The filepath of hellow.bat is probably a local path on the server. You create Job object on the client side and you pass this Job object to the server. How does the Job object (on the client side) know that the job is intended to be run on the server instead on the client where the job is created? Why do you create the Job object on the client side where it will never be executed? My suggestion is to move the job.Job() related code from the client to the server and just pass the three strings to the server. Then the Job object is created on the server side where it will be executed. The client can still influence the environment, the argument and the cmd. In case you want that the files for the environment and the commands are actually supplied by the client to the server you can handle this by supplying a callable (callback function) to the server to access local files on the client. (You might want to limit the access to certain files or dirs for security reasons). Some time ago I wrote a numerical client server tool (Monte Carlo Simualtion) with rpyc where a client can employ a number of servers to do repeated calculations. The code of for the calculations is supplied by the client (using xml). The server communcates the calculation results back to the client using numpy arrays. At the end the system could handle any number of servers with any number of simultanious (different) jobs and clients. By definition one client could execute one job at a time. I think this pattern was similar to yours and it was rather straight forward to implement it by using rpyc. In case you use callback from the server to the client you need to make sure that a thread is listening for incomming rpyc request from the server on the client side while the server is working. Greetings Rüdiger 2015-09-21 14:43 GMT+02:00 Michael Mann <[email protected]>: > Simplified code below... > > > *SERVER CODE:* > > > #!/usr/bin/env python > import os > import util > import job > import multiprocessing > import rpyc > > class MyClass(rpyc.Service): > """ Manages jobs requested on a Node instance""" > > def exposed_submitJobObj(self,newJob): > """Create a new Job using the input arguments""" > > self.addJobToQueue(newJob) > > > def addJobToQueue(self,newJob): > """Adds a new job to the node job execution queue and executes > it""" > > #execute the job in a new thread > myJobWorker = multiprocessing.Process(target=self.jobWorker, args > =(newJob,)) > myJobWorker.start() > > > def jobWorker(self,currJob): > """Multiprocess method to run job as a parallel process """ > currJob.execute() > > > def startNode(): > > > from rpyc.utils.server import ThreadedServer > t = ThreadedServer(NodeManager, port = 18861, protocol_config = { > "allow_public_attrs" : True,"allow_pickle":True}) > t.start() > > > if __name__ == '__main__': > startNode() > > > > *CLIENT CODE:* > > #!/usr/bin/env python > import os > import job > import util > import rpyc > > def testJobWrapper(): > > c = rpyc.connect("localhost", 18861, config = {"allow_public_attrs" : > True,"allow_pickle":True}) > > winenv='C:\\mydir\\mysubdir\\test.env' > winarg=['param1'] > wincmd = 'C:\\mydir\\mysubdir\\hellow.bat' > winJob = job.Job(wincmd,winarg) > testJob = job.JobWrapper() > testJob.setJobAttributes(winenv,winJob) > c.root.exposed_submitJobObj(testJob) > > > if __name__ == '__main__': > #testJob() > testJobWrapper() > > > -- > > --- > You received this message because you are subscribed to the Google Groups > "rpyc" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- --- You received this message because you are subscribed to the Google Groups "rpyc" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
