コード例 #1
0
class SockClient(object):
    def __init__(self, worker_addr, keep_alive=True):
        self.keep_alive = keep_alive
        self.worker_addr = worker_addr
        if self.keep_alive:
            sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
            sock.connect(worker_addr)
            self.port = ObjPort(sock)
        else:
            self.port = None

    def shutdown(self):
        if self.port:
            self.port.close()

    def __getattr__(self, func):
        if not self.port:
            return partial(remote_call, self.worker_addr, func)

        def call(*args):
            st = self.port.write((func, args))
            if st:
                msg = self.port.read()
                if msg:
                    return msg

        return call
コード例 #2
0
 def handle_let(self, sock):
     port = ObjPort(sock)
     while True:
         message = port.read()
         if message:
             port.write(self.handle(message))
         else:
             break
コード例 #3
0
 def __init__(self, worker_addr, keep_alive=True):
     self.keep_alive = keep_alive
     self.worker_addr = worker_addr
     if self.keep_alive:
         sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
         sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
         sock.connect(worker_addr)
         self.port = ObjPort(sock)
     else:
         self.port = None
コード例 #4
0
ファイル: sockserver.py プロジェクト: Tefx/Corellia
class SockClient(object):
	def __init__(self, worker_addr):
		sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
		sock.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
		sock.connect(worker_addr)
		self.port = ObjPort(sock)

	def shutdown(self):
		self.port.close()

	def __getattr__(self, func):
		def call(*args):
			st = self.port.write((func, args))
			if st:
				msg = self.port.read()
				if msg:
					return msg
		return call
コード例 #5
0
ファイル: sockserver.py プロジェクト: Python3pkg/Corellia
class SockClient(object):
    def __init__(self, worker_addr):
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        sock.connect(worker_addr)
        self.port = ObjPort(sock)

    def shutdown(self):
        self.port.close()

    def __getattr__(self, func):
        def call(*args):
            st = self.port.write((func, args))
            if st:
                msg = self.port.read()
                if msg:
                    return msg

        return call
コード例 #6
0
def remote_call(addr, func, *args):
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.connect(addr)
    port = ObjPort(sock)
    port.write((func, args))
    return port.read()
コード例 #7
0
ファイル: sockserver.py プロジェクト: Python3pkg/Corellia
 def __init__(self, worker_addr):
     sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
     sock.connect(worker_addr)
     self.port = ObjPort(sock)
コード例 #8
0
ファイル: sockserver.py プロジェクト: Tefx/Corellia
	def __init__(self, worker_addr):
		sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
		sock.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
		sock.connect(worker_addr)
		self.port = ObjPort(sock)