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


Python Client.recv_bytes方法代码示例

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


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

示例1: run

# 需要导入模块: from multiprocessing.connection import Client [as 别名]
# 或者: from multiprocessing.connection.Client import recv_bytes [as 别名]
 def run(self):
     address = ("localhost", 6000)
     conn = Client(address, authkey="secret password")
     while True:
         command = conn.recv_bytes()
         if command == "quit":
             break
         self.animations[:] = parse_command(command, self.boxs, "receiver")
     conn.close()
开发者ID:likang,项目名称:Reflekt,代码行数:11,代码来源:Reflekt.py

示例2: __delete__

# 需要导入模块: from multiprocessing.connection import Client [as 别名]
# 或者: from multiprocessing.connection.Client import recv_bytes [as 别名]
class ServiceConnect:
  def __delete__(self):
    if self.conn:
      self.conn.close()

  def conntect(self, host="localhost", port=6000):
    self.conn = Client((host, port))

  def request(self, req):
    self.conn.send(req)
    items = self.conn.recv_bytes()
    result = json.loads(items)
    return result
开发者ID:lijianxin,项目名称:Python-API,代码行数:15,代码来源:flask_web_api.py

示例3: terms_client

# 需要导入模块: from multiprocessing.connection import Client [as 别名]
# 或者: from multiprocessing.connection.Client import recv_bytes [as 别名]
def terms_client(config):
    '''
    CLI for terms server
    '''
    while True:
        terms = raw_input('>> ')
        if terms in ('quit', 'q', 'exit'):
            break
        conn = Client((config('kb_host'),
                        int(config('kb_port'))))
        conn.send_bytes(terms)
        conn.send_bytes('FINISH-TERMS')
        recv, resp = '', ''
        while recv != 'END':
            resp = recv
            recv = conn.recv_bytes()
            print(recv)
        conn.close()
    print('bye!')
开发者ID:enriquepablo,项目名称:terms.server,代码行数:21,代码来源:utils.py

示例4: do_execute

# 需要导入模块: from multiprocessing.connection import Client [as 别名]
# 或者: from multiprocessing.connection.Client import recv_bytes [as 别名]
    def do_execute(self, code, silent, store_history=True, user_expressions=None,
                   allow_stdin=False):
        conn = Client((self.host, self.port))
        conn.send_bytes(bytes(code, 'UTF-8'))
        conn.send_bytes(bytes('FINISH-TERMS', 'UTF-8'))
        recv, resp = bytes(), str()
        while recv != b'END':
            if recv:
                resp += ', ' + recv.decode('UTF-8')
            recv = conn.recv_bytes()
        conn.close()
        if not silent:
            stream_content = {'name': 'stdout', 'text': resp}
            self.send_response(self.iopub_socket, 'stream', stream_content)

        return {'status': 'ok',
                # The base class increments the execution count
                'execution_count': self.execution_count,
                'payload': [],
                'user_expressions': {},
               }
开发者ID:enriquepablo,项目名称:terms-docker,代码行数:23,代码来源:terms_kernel.py

示例5: run

# 需要导入模块: from multiprocessing.connection import Client [as 别名]
# 或者: from multiprocessing.connection.Client import recv_bytes [as 别名]
 def run(self, cmd):
     '''
     传递命令给server, 同时展示传回信息.
     @ cmd: 命令, 以tab分割.
     '''
     conn = MultiClient(
         (config.hostname, config.port),
         authkey=config.authkey,
     )
     # 传送命令
     conn.send(cmd)
     try:
         # 收取信息
         recv_data = conn.recv_bytes()
     except EOFError:
         pass
     else:
         # 传回的数据是unicode编码的
         unicode_recv_data = eval(recv_data)
         # 按照设定编码print反馈数据
         print unicode_recv_data.encode(config.client_code)
     finally:
         conn.close()
开发者ID:hyb,项目名称:jing.fm,代码行数:25,代码来源:client.py

示例6: work

# 需要导入模块: from multiprocessing.connection import Client [as 别名]
# 或者: from multiprocessing.connection.Client import recv_bytes [as 别名]
 def work(self):
     conn = Client(self.address, authkey=self.password)
     print conn.recv_bytes()
     conn.close()
开发者ID:clairvoyant,项目名称:grimoire,代码行数:6,代码来源:manager.py

示例7: Wdb

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

#.........这里部分代码省略.........
        for i, (stack_frame, lno) in enumerate(stack):
            code = stack_frame.f_code
            filename = code.co_filename
            linecache.checkcache(filename)
            line = linecache.getline(filename, lno, stack_frame.f_globals)
            line = to_unicode_string(line, filename)
            line = line and line.strip()
            startlnos = dis.findlinestarts(code)
            lastlineno = list(startlnos)[-1][1]
            frames.append({
                'file': filename,
                'function': code.co_name,
                'flno': code.co_firstlineno,
                'llno': lastlineno,
                'lno': lno,
                'code': line,
                'level': i,
                'current': current == i
            })

        # While in exception always put the context to the top
        current = len(frames) - 1

        return stack, frames, current

    def send(self, data):
        """Send data through websocket"""
        log.debug('Sending %s' % data)
        self._socket.send_bytes(data.encode('utf-8'))

    def receive(self, pickled=False):
        """Receive data through websocket"""
        log.debug('Receiving')
        data = self._socket.recv_bytes()
        if pickled:
            data = pickle.loads(data)
            log.debug('Got pickled %r' % data)
            return data
        log.debug('Got %s' % data)
        return data.decode('utf-8')

    def interaction(
            self, frame, tb=None,
            exception='Wdb', exception_description='Stepping',
            init=None):
        """User interaction handling blocking on socket receive"""
        log.info('Interaction for %r -> %r %r %r %r' % (
            self.thread, frame, tb, exception, exception_description))
        self.stepping = True

        if not self.connected:
            self.connect()
            log.debug('Launching browser and wait for connection')
            web_url = 'http://%s:%d/debug/session/%s' % (
                WEB_SERVER or 'localhost',
                WEB_PORT or 1984,
                self.uuid)

            server = WEB_SERVER or '[wdb.server]'
            if WEB_PORT:
                server += ':%s' % WEB_PORT

            if WDB_NO_BROWSER_AUTO_OPEN:
                log.warning('You can now launch your browser at '
                            'http://%s/debug/session/%s' % (
                                server,
开发者ID:cristen,项目名称:wdb,代码行数:70,代码来源:__init__.py

示例8: client

# 需要导入模块: from multiprocessing.connection import Client [as 别名]
# 或者: from multiprocessing.connection.Client import recv_bytes [as 别名]
def client(msg):
    conn = Client(address, authkey=b'mypassword')
    conn.send(msg)
    print (conn.recv())
    print (conn.recv_bytes())
    conn.close()
开发者ID:miki1029,项目名称:Python_Basic,代码行数:8,代码来源:process10.py

示例9: Client

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

address = ('localhost', 6000)
conn = Client(address, authkey='secret password')

print conn.recv()                 # => [2.25, None, 'junk', float]

print conn.recv_bytes()            # => 'hello'

arr = array('i', [0, 0, 0, 0, 0])
print conn.recv_bytes_into(arr)     # => 8
print arr                         # => array('i', [42, 1729, 0, 0, 0])

conn.close()
开发者ID:zy-sunshine,项目名称:python-logging-socket,代码行数:17,代码来源:t-mp-listen-client.py

示例10: range

# 需要导入模块: from multiprocessing.connection import Client [as 别名]
# 或者: from multiprocessing.connection.Client import recv_bytes [as 别名]
# -*- coding: utf-8 -*-

from multiprocessing.connection import Client

address = ('localhost', 8000)

for x in range(0,5):
    conn = Client(address, authkey='secret password')
    conn.send('这是一个美丽的世界')
    print conn.recv_bytes()

    conn.close()
开发者ID:atupal,项目名称:snippet,代码行数:14,代码来源:client.py

示例11: RemoteGdb

# 需要导入模块: from multiprocessing.connection import Client [as 别名]
# 或者: from multiprocessing.connection.Client import recv_bytes [as 别名]
class RemoteGdb(object):
    def __init__(self, vim, host, port):
        self.vim = vim
        self.sock = Client((host, port))
        self.request_id = 0
        self.response = {}

    def send_command(self, **kwargs):
        self.request_id += 1
        try:
            self.sock.send_bytes(json.dumps(dict(dict({'dest': 'gdb'}, **kwargs), request_id=self.request_id)).encode('utf-8'))
        except IOError:
            print "Broken pipe encountered sending to the proxy.  Terminating Exterminator."
            self.quit()
        return self.request_id

    def handle_events(self):
        if not self.sock.poll():
            return
        while True:
            try:
                c = json.loads(self.sock.recv_bytes().decode('utf-8'))
            except (IOError, EOFError):
                print "Lost connection to GDB"
                self.quit()
                return
            if c['op'] == 'goto':
                window = self.find_window('navigation')
                if window is None:
                    self.claim_window('navigation')
                c['filename'] = os.path.abspath(c['filename'])
                self.vim.command('badd %(filename)s' % c)
                self.vim.command("buffer %(filename)s" % c)
                self.vim.command("%(line)s" % c)
                self.vim.command("%(line)skP" % c)
                self.vim.command("norm zz")
            elif c['op'] == 'disp':
                winnr = int(self.vim.eval("winnr()"))
                window = self.find_window('display', 'bot 15new')
                self.vim.command("setlocal buftype=nowrite bufhidden=wipe modifiable nobuflisted noswapfile nowrap nonumber")
                contents = [ c['expr'], c['contents'] ]
                self.vim.current.window.buffer[:] = contents
                self.vim.command("setlocal nomodifiable")
                self.vim.command("%swincmd w" % winnr)
            elif c['op'] == 'response':
                self.response[c['request_id']] = c
            elif c['op'] == 'refresh':
                GDBPlugin = self.vim.bindeval('g:NERDTreeGDBPlugin')
                NERDTreeFromJSON = self.vim.Function('NERDTreeFromJSON')
                NERDTreeFromJSON(c['expr'], GDBPlugin)
            elif c['op'] == 'place':
                c['filename'] = os.path.abspath(c['filename'])
                self.vim.command("badd %s" % c['filename'].replace('$', '\\$'))
                c['bufnr'] = self.vim.eval("bufnr('%(filename)s')" % c)
                self.vim.command("sign place %(num)s name=%(name)s line=%(line)s buffer=%(bufnr)s" % c)
            elif c['op'] == 'replace':
                self.vim.command("sign place %(num)s name=%(name)s file=%(filename)s" % c)
            elif c['op'] == 'unplace':
                self.vim.command("sign unplace %(num)s" % c)
            elif c['op'] == 'quit':
                self.quit()
                return
            if not self.sock.poll():
                return

    def quit(self):
        self.vim.command("sign unplace *")
        winnr = int(self.vim.eval("winnr()"))
        window = self.find_window('display')
        if window is not None:
            self.vim.command("q")
        self.vim.command("%swincmd w" % winnr)
        self.vim.gdb = None
        try:
            self.send_command(dest='proxy', op='quit')
        except:
            pass

    def send_trap(self):
        self.send_command(dest='proxy', op='trap')

    def send_quit(self):
        self.send_command(op='quit')

    def send_continue(self):
        self.send_command(op='go')
        self.send_trap()

    def send_exec(self, comm):
        self.send_command(op='exec', comm=comm)
        self.send_trap()

    def disable_break(self, filename, line):
        self.send_command(op='disable', loc=(filename, line))
        self.send_trap()

    def toggle_break(self, filename, line):
        self.send_command(op='toggle', loc=(filename, line))
        self.send_trap()

#.........这里部分代码省略.........
开发者ID:tomov,项目名称:dotfiles,代码行数:103,代码来源:vim_exterminator.py

示例12: Environment

# 需要导入模块: from multiprocessing.connection import Client [as 别名]
# 或者: from multiprocessing.connection.Client import recv_bytes [as 别名]
class Environment(object):
    """Supplement server client"""

    def __init__(self, executable=None, env=None, logfile=None):
        """Environment constructor

        :param executable: path to python executable. May be path to virtualenv interpreter
              start script like ``/path/to/venv/bin/python``.

        :param env: environment variables dict, e.g. ``DJANGO_SETTINGS_MODULE`` value.

        :param logfile: explicit log file, can be passed via environment SUPP_LOG_FILE
        """
        self.executable = executable or sys.executable
        self.env = env
        self.logfile = logfile

        self.prepare_thread = None
        self.prepare_lock = Lock()

    def _run(self):
        from subprocess import Popen
        from multiprocessing.connection import Client, arbitrary_address

        if sys.platform == 'win32':
            addr = arbitrary_address('AF_PIPE')
        else:
            addr = arbitrary_address('AF_UNIX')

        supp_server = os.path.join(os.path.dirname(__file__), 'server.py')
        args = [self.executable, supp_server, addr]

        env = os.environ.copy()
        if self.env:
            env.update(self.env)

        if self.logfile and 'SUPP_LOG_FILE' not in env:
            env['SUPP_LOG_FILE'] = self.logfile

        self.proc = Popen(args, env=env)

        start = time.time()
        while True:
            try:
                self.conn = Client(addr)
            except Exception as e:
                if time.time() - start > 5:
                    raise Exception('Supp server launching timeout exceed: ' + str(e))

                time.sleep(0.3)
            else:
                break

    def _threaded_run(self):
        try:
            self._run()
        finally:
            self.prepare_thread = None

    def prepare(self):
        with self.prepare_lock:
            if self.prepare_thread:
                return

            if hasattr(self, 'conn'):
                return

            self.prepare_thread = Thread(target=self._threaded_run)
            self.prepare_thread.start()

    def run(self):
        with self.prepare_lock:
            if self.prepare_thread:
                self.prepare_thread.join()

            if not hasattr(self, 'conn'):
                self._run()

    def _call(self, name, *args, **kwargs):
        try:
            self.conn
        except AttributeError:
            self.run()

        self.conn.send_bytes(dumps((name, args, kwargs)))
        result, is_ok = loads(self.conn.recv_bytes())

        if is_ok:
            return result
        else:
            raise Exception(result[1])

    def lint(self, source, filename, syntax_only=False):
        return self._call('lint', source, filename, syntax_only)

    def assist(self, source, position, filename):
        """Return completion match and list of completion proposals

        :param source: code source
        :param position: tuple of (line, column)
#.........这里部分代码省略.........
开发者ID:baverman,项目名称:supp,代码行数:103,代码来源:remote.py

示例13: _get_conn

# 需要导入模块: from multiprocessing.connection import Client [as 别名]
# 或者: from multiprocessing.connection.Client import recv_bytes [as 别名]
 def _get_conn(self):
     conn_in = Client(self.address, authkey=b'testingToms')
     if self.strat == 'pipe':
         return conn_in.recv()
     buf = io.BytesIO(conn_in.recv_bytes())
     return pickle.load(buf)
开发者ID:tomMoral,项目名称:multiprocess_backend,代码行数:8,代码来源:queue.py


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