def _handleRequest_Threaded(self,timeout,others,callback): # self.connections is used to keep track of connection Threads socklist = [self.sock]+others if timeout==None: ins,outs,exs = select.select(socklist,[],[]) else: ins,outs,exs = select.select(socklist,[],[],timeout) if self.sock in ins: # it was the server socket, new incoming connection if self._ssl_server: from M2Crypto import SSL try: csock, addr = self.sock.accept() sslsock = SSL.Connection(self.ctx,csock) sslsock.setup_addr(addr) sslsock.setup_ssl() sslsock.set_accept_state() sslsock.accept_ssl() except SSL.SSLError,error: Log.warn('TCPServer','SSL error: '+str(error)) print "SSL Error:",error csock.close() return csock=sslsock else: csock, addr = self.sock.accept() conn=TCPConnection(csock,addr) thread=Thread(target=self.connectionHandler, args=(conn,)) thread.setDaemon(1) # thread must exit at program termination. thread.localStorage=LocalStorage() self.initTLS(thread.localStorage) self.connections.append(thread) thread.start()
def _handleRequest_Threaded(self,timeout,others,callback): # self.connections is used to keep track of connection Threads socklist = [self.sock]+others ins,outs,exs = safe_select(socklist,[],[],timeout) if self.sock in ins: # it was the server socket, new incoming connection if self._ssl_server: try: csock, addr = self.sock.accept() #if not Pyro.config.PYROSSL_POSTCONNCHECK: # csock.postConnectionCheck=None except SSL.SSLError,error: Log.warn('TCPServer','SSL error: '+str(error)) return else: csock, addr = self.sock.accept() conn=TCPConnection(csock,addr) thread=Thread(target=self.connectionHandler, args=(conn,)) thread.setDaemon(1) # thread must exit at program termination. thread.localStorage=LocalStorage() self.connections.append(thread) thread.start()
return try: # find the object in the implementation database of our daemon o=daemon.getLocalObject(req[0]) except (KeyError, TypeError) ,x: Log.warn('PYROAdapter','Invocation to unknown object ignored:',x) self.returnException(conn, ProtocolError('unknown object ID')) return else: # Do the invocation. We are already running in our own thread. if req[2]&Pyro.constants.RIF_Oneway and Pyro.config.PYRO_ONEWAY_THREADED and daemon.threaded: # received a oneway call, run this in its own thread. thread=Thread(target=self._handleInvocation2, args=(daemon,req,pflags,conn,o,True)) thread.setDaemon(1) # thread must exit at program termination. thread.localStorage=LocalStorage() # set local storage for the new thread thread.start() else: # not oneway or not in threaded mode, just do the invocation synchronously self._handleInvocation2(daemon,req,pflags,conn,o,False) def _handleInvocation2(self, daemon, req, pflags, conn, obj, mustInitTLS=False): if mustInitTLS: daemon.initTLS(daemon.getLocalStorage()) try: flags=req[2] importer=None if not Pyro.config.PYRO_MOBILE_CODE: res = obj.Pyro_dyncall(req[1],flags,req[3]) # (method,flags,args) else: try:
return try: # find the object in the implementation database of our daemon o=daemon.getLocalObject(req[0]) except (KeyError, TypeError) ,x: Log.warn('PYROAdapter','Invocation to unknown object ignored:',x) self.returnException(conn, ProtocolError('unknown object ID')) return else: # Do the invocation. We are already running in our own thread. if req[2]&Pyro.constants.RIF_Oneway and Pyro.config.PYRO_ONEWAY_THREADED and daemon.threaded: # received a oneway call, run this in its own thread. thread=Thread(target=self._handleInvocation2, args=(daemon,req,pflags,conn,o)) thread.setDaemon(1) # thread must exit at program termination. thread.localStorage=daemon.getLocalStorage() # set local storage for the new thread thread.start() else: # not oneway or not in threaded mode, just do the invocation synchronously self._handleInvocation2(daemon,req,pflags,conn,o) def _handleInvocation2(self, daemon, req, pflags, conn, obj): try: flags=req[2] importer=None if not Pyro.config.PYRO_MOBILE_CODE: res = obj.Pyro_dyncall(req[1],flags,req[3]) # (method,flags,args) else: try: # install a custom importer to intercept any extra needed modules # when executing the remote method. (using the data passed in by