当前位置: 首页>>代码示例>>Python>>正文


Python Client.send方法代码示例

本文整理汇总了Python中multiprocessing.connection.Client.send方法的典型用法代码示例。如果您正苦于以下问题:Python Client.send方法的具体用法?Python Client.send怎么用?Python Client.send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在multiprocessing.connection.Client的用法示例。


在下文中一共展示了Client.send方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: communicate

# 需要导入模块: from multiprocessing.connection import Client [as 别名]
# 或者: from multiprocessing.connection.Client import send [as 别名]
def communicate(message):
    address = ('localhost',6345)
    conn = Client(address)
    conn.send(message)
    reply = conn.recv()
    conn.close()
    return reply
开发者ID:dsanderson,项目名称:design-space-generator,代码行数:9,代码来源:server.py

示例2: get_json

# 需要导入模块: from multiprocessing.connection import Client [as 别名]
# 或者: from multiprocessing.connection.Client import send [as 别名]
def get_json():
    # Get the current values
    c = Client(("localhost", 25000))
    c.send("get")
    now = c.recv()

    # Now we parse all the data out of the results!
    data = {}
    data["IN_Temp"] = now.In_Temp
    data["IN_Humid"] = now.In_Humid
    data["OUT_Temp"] = now.Out_Temp
    data["OUT_Humid"] = now.Out_Humid
    data["Out_Wind_Now"] = now.Out_Wind_Now
    data["OUT_Wind_Avg"] = now.Out_Wind_Avg
    data["OUT_Wind_Max"] = now.Out_Wind_Max
    data["OUT_Rain_Today"] = now.Out_Rain_Today
    data["OUT_Rain_Last_24h"] = now.Out_Rain_Last_24h
    data["OUT_Rain_Since_Reset"] = now.Out_Rain_Since_Reset
    data["ATTIC_Temp"] = now.Attic_Temp
    data["ATTIC_Humid"] = now.Attic_Humid
    data["NOW_URL"] = now.Now_URL
    data["NOW_Feel"] = now.Now_Feel
    data["NOW_Feel_High"] = now.Now_Feel_High
    data["NOW_Feel_Low"] = now.NOW_Feel_Low
    data["SYSTEM_CPU"] = now.System_CPU
    data["SYSTEM_RAM"] = now.System_RAM

    # Now return the json as a string
    return json.dumps(data)
开发者ID:1n5aN1aC,项目名称:rainmeter-pi,代码行数:31,代码来源:http_status.py

示例3: send

# 需要导入模块: from multiprocessing.connection import Client [as 别名]
# 或者: from multiprocessing.connection.Client import send [as 别名]
 def send(self, msg):
     # TODO: Busy wait will do for initial startup but for dealing with server down in the middle of things
     # TODO: then busy wait is probably inappropriate.
     if self.port == 5555:
         self.redis.rpush('flowqueue', msg)
     else:
         while True: # keep going until we break out inside the loop
             try:
                 self.logger.debug('Attempting to connect to '+self.serverName+' server at '+str(self.address)+' port '+str(self.port))
                 conn = Client((self.address, self.port))
                 self.logger.debug('Connect to '+self.serverName+' successful.')
                 break
             except SocketError as serr:
                 if serr.errno == errno.ECONNREFUSED:
                     self.logger.debug('Connect to '+self.serverName+' failed because connection was refused (the server is down). Trying again.')
                 else:
                     # Not a recognized error. Treat as fatal.
                     self.logger.debug('Connect to '+self.serverName+' gave socket error '+str(serr.errno))
                     raise serr
             except:
                 self.logger.exception('Connect to '+self.serverName+' threw unknown exception')
                 raise
         self.logger.debug('PCTRLSEND ' + str(msg))
         conn.send(msg)
         self.logger.debug('TRYCONNCLOSE trying to close the connection in pctrl')
         conn.close()
开发者ID:jeroen92,项目名称:iSDX,代码行数:28,代码来源:lib.py

示例4: triggerEvent

# 需要导入模块: from multiprocessing.connection import Client [as 别名]
# 或者: from multiprocessing.connection.Client import send [as 别名]
def triggerEvent( type, scheduleMethod, *args ):
    """
    This function inserts an event into CHOTestMonkey
    """
    host = "localhost"
    port = 6000
    address = ( host, port )
    conn = Client( address )
    request = []
    request.append( 1 )
    request.append( type )
    request.append( scheduleMethod )
    for arg in args:
        request.append( arg )
    conn.send( request )
    response = conn.recv()
    while response == 11:
        conn.close()
        time.sleep( 1 )
        conn = Client( address )
        conn.send( request )
        response = conn.recv()
    if response == 10:
        print "Event inserted:", type, scheduleMethod, args
    elif response == 20:
        print "Unknown message to server"
    elif response == 21:
        print "Unknown event type to server"
    elif response == 22:
        print "Unknown schedule method to server"
    elif response == 23:
        print "Not enough argument"
    else:
        print "Unknown response from server:", response
    conn.close()
开发者ID:opennetworkinglab,项目名称:OnosSystemTest,代码行数:37,代码来源:EventTrigger.py

示例5: call

# 需要导入模块: from multiprocessing.connection import Client [as 别名]
# 或者: from multiprocessing.connection.Client import send [as 别名]
        def call(*args, **kwargs):
            global _recursive_conn_lock
            if _recursive_conn_lock:
                raise AssertionError, 'BUG: Recursive client connection'
                # Avoid hanging because we call the socket while the
                # server is blocking for our return value on the pipe.
                # If this is an issue blocking functionality,
                # re-route the call to the open pipe for which the
                # server is waiting.

            #~ if self._client_proxy_authkey is None:
                #~ self._client_proxy_authkey = AUTHKEY_FILE.raw()

            msg = RemoteMethodCall(self._obj, name, args, kwargs)
            logger.debug('Remote call from %i: %s', os.getpid(), msg)
            #~ print "CLIENT >>%s<<" % self._client_proxy_authkey
            #~ conn = Client(SERVER_ADDRESS, authkey=self._client_proxy_authkey)
            conn = Client(SERVER_ADDRESS, SERVER_ADDRESS_FAMILY)
            conn.send(msg)
            if not msg.async:
                re = conn.recv()
                logger.debug('Remote call returned to %i: %s', os.getpid(), re)
                if isinstance(re, Exception):
                    raise re
                else:
                    return re
开发者ID:DarioGT,项目名称:Zim-QDA,代码行数:28,代码来源:ipc.py

示例6: start_server

# 需要导入模块: from multiprocessing.connection import Client [as 别名]
# 或者: from multiprocessing.connection.Client import send [as 别名]
 def start_server(self, address, password):
     print("server waiting")
     listener = Listener()
     client = Client(address)
     client.send(listener.address)
     self._start_listener(listener)
     return listener.address
开发者ID:Benhgift,项目名称:note_study_tool,代码行数:9,代码来源:notebook.py

示例7: shutdown_metric

# 需要导入模块: from multiprocessing.connection import Client [as 别名]
# 或者: from multiprocessing.connection.Client import send [as 别名]
def shutdown_metric(metric_server_addresses, authkey):
    """ This function tells all of the SimulationPotential instances running on the addresses in metric_server_addresses to shutdown. This is called when a SimulationClient instance shuts down.

    Args:
      metric_server_addresses: A list of tuples of the form (str, int) containing the hostnames and port numbers of the SimulationPotential instances.
      authkey (str): The password used in order to communicate with the SimulationPotential instances.

    Returns:
      float: The length of the curve with metric values in metric.

    """

    # For each SimulationPotential instance...
    for address in xrange(len(metric_server_addresses)):

        # Try making contact with the SimulationPotential instance...
        try:
            # Establish a connection with the SimulationPotential
            metric_server = Client(metric_server_addresses[address], authkey=authkey)

            # Send a status code indicating the SimulationPotential instance should stop running.
            metric_server.send({'status_code': comm_code('KILL')})

            # Close the connection.
            metric_server.close()

        # If contact with the SimulationPotential instance cannot be made then...
        except socket.error:
            # Make a note in the log which SimulationPotential couldn't be contacted.
            logging.warning('Failed to Make Connection to SimulationPotential at '
                          + str(metric_server_addresses[address]) + '.')
开发者ID:suttond,项目名称:MODOI,代码行数:33,代码来源:MetricValues.py

示例8: send

# 需要导入模块: from multiprocessing.connection import Client [as 别名]
# 或者: from multiprocessing.connection.Client import send [as 别名]
    def send(self, msg):
        #conn = Client((self.address, self.port), authkey=str(self.key))
        conn = Client((self.address, self.port))

        conn.send(json.dumps(msg))

        conn.close()
开发者ID:chengguozhen,项目名称:iSDX,代码行数:9,代码来源:client.py

示例9: send

# 需要导入模块: from multiprocessing.connection import Client [as 别名]
# 或者: from multiprocessing.connection.Client import send [as 别名]
 def send(self, packet):
     address = ('localhost', self.port)
     conn = Client(address, authkey=self.pwd)
     self._printDebug("MultiBus,Client: send")
     conn.send(packet)
     conn.send('close')
     conn.close()
开发者ID:former-hyperion-project,项目名称:multibus,代码行数:9,代码来源:busclient.py

示例10: Worker

# 需要导入模块: from multiprocessing.connection import Client [as 别名]
# 或者: from multiprocessing.connection.Client import send [as 别名]
class Worker(object):

    def __init__(self, address, port, authkey=None):

        self.connection = Client((address, port), authkey=authkey)
        self.worker_id = self.connection.recv()

    def run(self):
        while True:

            task_data = self.connection.recv()
            if task_data is False:
                return

            result = self.do_task(task_data)
            self.connection.send((task_data, result))

    def log(self, *items):
        print "== Worker %s ==" % self.worker_id,
        for item in items:
            print item,
        print

    def do_task(self, data):
        raise NotImplementedError("A subclass must implement this.")
开发者ID:AmesianX,项目名称:des,代码行数:27,代码来源:distproc.py

示例11: __enter__

# 需要导入模块: from multiprocessing.connection import Client [as 别名]
# 或者: from multiprocessing.connection.Client import send [as 别名]
class RsClient:

	def __enter__(self):
		"""no init"""

	def __exit__(self, type=None, value=None, tb=None):

		#self.conn may not exist so expect that it may fail.
		try:
			self.conn.close()
		except:
			pass

	def start(self, host='localhost', port=8000, key='8457#$%^&3648'):

		address = (host, port)
		self.conn = Client(address)

	def send(self, data):
		try:
			self.conn.send(data)
		except:
			self.stop()

	def stop(self):
		self.conn.close()
开发者ID:RhinoLance,项目名称:PythonProcessQueue,代码行数:28,代码来源:Communicator.py

示例12: ThreadedExponentClient

# 需要导入模块: from multiprocessing.connection import Client [as 别名]
# 或者: from multiprocessing.connection.Client import send [as 别名]
class ThreadedExponentClient(ExponentClient):
    def __init__(self, ip, port, password):
        super(ThreadedExponentClient, self).__init__(ip, port, password)

        self.conn = Client((self.ip, self.port))

    def _auth(self, password):
        self.conn.send(password)
        auth_value = self.conn.recv()

        if auth_value == 'AUTH':
            print("Authorized")
            return True
        else:
            raise RuntimeError("Invalid Password")
            return False

    def __del__(self):
        print("Entering del")
        if self.__dict__.get('conn') != None:
            self.conn.close()

    def send(self, value):
        self.conn.send(value)
        return self.conn.recv()
开发者ID:cylussec,项目名称:pythonserver,代码行数:27,代码来源:client.py

示例13: ConnectClient

# 需要导入模块: from multiprocessing.connection import Client [as 别名]
# 或者: from multiprocessing.connection.Client import send [as 别名]
class ConnectClient():
    address = None
    conn = None
    
    def __init__(self, ip = 'localhost', port = 7000):
        self.address = (ip, port)
        self.conn = Client(self.address)

    def __del__(self):
        self.conn.close()
    
    def register_module(self, process_file):
        """send and register a module in the server"""
        f = open(process_file, "rb")
        l = f.read()
        self.conn.send([0, l])
        f.close()

    def request_process(self, args):
        """request the server to do a process previously sent in a module"""
        self.conn.send([1, args[0]] + args[1:])
        answer = self.conn.recv()
        if isinstance(answer, Exception):
            raise answer
        return answer
开发者ID:kahbum,项目名称:Python_Distributed_System,代码行数:27,代码来源:Client.py

示例14: __init__

# 需要导入模块: from multiprocessing.connection import Client [as 别名]
# 或者: from multiprocessing.connection.Client import send [as 别名]
class UIListener:
    def __init__(self, address, port, authkey):
        self.client = Client((address, port), authkey=authkey)

    def get_args(self, n):
        return [self.client.recv() if self.client.poll(0.5) else None for _ in range(n)]

    def listenloop(self):
        keepalive = True

        try:
            while keepalive:
                while self.client.poll():
                    data = self.client.recv()
                    print('{}: {}'.format('x64' if utils.is64bit() else 'x86', data))

                    if data == 'close':
                        keepalive = False
                    else:
                        func = _interface[data]
                        self.client.send(func(*self.get_args(func.__code__.co_argcount)))
                        print('{}: sent response to {}'.format('x64' if utils.is64bit() else 'x86', data))

                time.sleep(0.05)
        except EOFError or ConnectionError:
            pass

            self.client.close()
开发者ID:TehVulpes,项目名称:WinAutomate,代码行数:30,代码来源:uilistener.py

示例15: LockOutputFrequency

# 需要导入模块: from multiprocessing.connection import Client [as 别名]
# 或者: from multiprocessing.connection.Client import send [as 别名]
class LockOutputFrequency(ExternalParameterBase):

    className = "Digital Lock Output Frequency"
    _outputChannels = {"OutputFrequency": "MHz", "Harmonic": ""}

    def __init__(self, name, config, globalDict, instrument="localhost:16888"):
        logger = logging.getLogger(__name__)
        ExternalParameterBase.__init__(self, name, config, globalDict)
        logger.info( "trying to open '{0}'".format(instrument) )
        host, port = instrument.split(':')
        self.instrument = Client((host, int(port)), authkey=b"yb171")
        logger.info( "opened {0}".format(instrument) )
        self.setDefaults()
        self.initializeChannelsToExternals()
        
    def setValue(self, channel, v):
        self.instrument.send( ('set{0}'.format(channel), (v, ) ) )
        result = self.instrument.recv()
        if isinstance(result, Exception):
            raise result
        return result
        
    def getValue(self, channel):
        self.instrument.send( ('get{0}'.format(channel), tuple() ) )
        result = self.instrument.recv()
        if isinstance(result, Exception):
            raise result
        return result
        
    def close(self):
        del self.instrument
开发者ID:pyIonControl,项目名称:IonControl,代码行数:33,代码来源:InterProcessParameters.py


注:本文中的multiprocessing.connection.Client.send方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。