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


Python utils.merge_headers函数代码示例

本文整理汇总了Python中utils.merge_headers函数的典型用法代码示例。如果您正苦于以下问题:Python merge_headers函数的具体用法?Python merge_headers怎么用?Python merge_headers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: disconnect

 def disconnect(self, headers={}, **keyword_headers):
     """
     Send a DISCONNECT frame to finish a connection
     """
     self.__send_frame_helper('DISCONNECT', '', utils.merge_headers([self.__connect_headers, headers, keyword_headers]), [ ])
     self.__running = False
     if self.__socket is not None:
         if self.__ssl:
             #
             # Even though we don't want to use the socket, unwrap is the only API method which does a proper SSL shutdown
             #
             try:
                 self.__socket = self.__socket.unwrap()
             except Exception:
                 #
                 # unwrap seems flaky on Win with the backported ssl mod, so catch any exception and log it
                 #
                 _, e, _ = sys.exc_info()
                 log.warn(e)
         elif hasattr(socket, 'SHUT_RDWR'):
             self.__socket.shutdown(socket.SHUT_RDWR)
     #
     # split this into a separate check, because sometimes the socket is nulled between shutdown and this call
     #
     if self.__socket is not None:
         self.__socket.close()
     self.__current_host_and_port = None
开发者ID:TonyWildish,项目名称:DDM,代码行数:27,代码来源:connect.py

示例2: begin

 def begin(self, transaction=None, headers={}, **keyword_headers):
     headers = utils.merge_headers([headers, keyword_headers])
     if not transaction:
         transaction = str(uuid.uuid4())
     headers[HDR_TRANSACTION] = transaction
     self.__send_frame(CMD_BEGIN, headers)
     return transaction
开发者ID:victoradan,项目名称:stomp.py,代码行数:7,代码来源:protocol.py

示例3: nack

 def nack(self, headers={}, **keyword_headers):
     """
     Send an NACK frame, to acknowledge a message was not successfully processed
     """
     if self.version < 1.1:
         raise RuntimeError('NACK is not supported with 1.0 connections')
     self.__send_frame_helper('NACK', '', utils.merge_headers([headers, keyword_headers]), [ 'message-id' ])
开发者ID:uchitel206,项目名称:stomp.py,代码行数:7,代码来源:connect.py

示例4: connect

    def connect(self, username=None, passcode=None, wait=False, headers={}, **keyword_headers):
        """
        Send a STOMP CONNECT frame. Differs from 1.0 and 1.1 versions in that the HOST header is enforced.
        \param username
            optionally specify the login user
        \param passcode
            optionally specify the user password
        \param wait
            wait for the connection to complete before returning
        """
        cmd = CMD_STOMP
        headers = utils.merge_headers([headers, keyword_headers])
        headers[HDR_ACCEPT_VERSION] = self.version
        headers[HDR_HOST] = self.transport.current_host_and_port[0]
        
        if self.transport.vhost:
            headers[HDR_HOST] = self.transport.vhost

        if username is not None:
            headers[HDR_LOGIN] = username

        if passcode is not None:
            headers[HDR_PASSCODE] = passcode

        self.__send_frame(cmd, headers)
        
        if wait:
            self.transport.wait_for_connection()
            if self.connection_error:
                raise ConnectFailedException()
开发者ID:jucovschi,项目名称:Sublime-LMH,代码行数:30,代码来源:protocol.py

示例5: connect

 def connect(self, headers={}, **keyword_headers):
     """
     Send a CONNECT frame to start a connection
     """
     wait = False
     if 'wait' in keyword_headers and keyword_headers['wait']:
         wait = True
         del keyword_headers['wait']
         
     if self.version >= 1.1:
         if self.__strict:
             cmd = 'STOMP'
         else:
             cmd = 'CONNECT'
         if self.vhost is not None:
             headers['host'] = self.vhost
         headers['accept-version'] = self.version
         headers['heart-beat'] = '%s,%s' % self.heartbeats
     else:
         cmd = 'CONNECT'
     self.__send_frame_helper(cmd, '', utils.merge_headers([self.__connect_headers, headers, keyword_headers]), [ ])
     if wait:
         self.__connect_wait_condition.acquire()
         while not self.is_connected(): 
             self.__connect_wait_condition.wait()
         self.__connect_wait_condition.release()
开发者ID:uchitel206,项目名称:stomp.py,代码行数:26,代码来源:connect.py

示例6: unsubscribe

 def unsubscribe(self, destination=None, id=None, headers={}, **keyword_headers):
     assert id is not None or destination is not None, "'id' or 'destination' is required"
     headers = utils.merge_headers([headers, keyword_headers])
     if id:
         headers[HDR_ID] = id
     if destination:
         headers[HDR_DESTINATION] = destination
     self.__send_frame(CMD_UNSUBSCRIBE, headers)
开发者ID:victoradan,项目名称:stomp.py,代码行数:8,代码来源:protocol.py

示例7: subscribe

 def subscribe(self, destination, id=None, ack="auto", headers={}, **keyword_headers):
     assert destination is not None, "'destination' is required"
     headers = utils.merge_headers([headers, keyword_headers])
     headers[HDR_DESTINATION] = destination
     if id:
         headers[HDR_ID] = id
     headers[HDR_ACK] = ack
     self.__send_frame(CMD_SUBSCRIBE, headers)
开发者ID:victoradan,项目名称:stomp.py,代码行数:8,代码来源:protocol.py

示例8: connect

 def connect(self, headers={}, **keyword_headers):
     """
     Send a CONNECT frame to start a connection
     """
     if 'wait' in keyword_headers and keyword_headers['wait']:
         while not self.is_connected(): time.sleep(0.1)
         del keyword_headers['wait']
     self.__send_frame_helper('CONNECT', '', utils.merge_headers([self.__connect_headers, headers, keyword_headers]), [ ])
开发者ID:TonyWildish,项目名称:DDM,代码行数:8,代码来源:connect.py

示例9: subscribe

 def subscribe(self, headers={}, **keyword_headers):
     """
     Send a SUBSCRIBE frame to subscribe to a queue
     """
     merged_headers = utils.merge_headers([headers, keyword_headers])
     required_headers = [ 'destination' ]
     if self.version >= 1.1:
         required_headers.append('id')
     self.__send_frame_helper('SUBSCRIBE', '', merged_headers, required_headers)
开发者ID:uchitel206,项目名称:stomp.py,代码行数:9,代码来源:connect.py

示例10: begin

 def begin(self, headers={}, **keyword_headers):
     """
     Send a BEGIN frame to start a transaction
     """
     use_headers = utils.merge_headers([headers, keyword_headers])
     if not 'transaction' in use_headers.keys(): 
         use_headers['transaction'] = str(uuid.uuid4())
     self.__send_frame_helper('BEGIN', '', use_headers, [ 'transaction' ])
     return use_headers['transaction']
开发者ID:uchitel206,项目名称:stomp.py,代码行数:9,代码来源:connect.py

示例11: send

 def send(self, destination, body, content_type=None, headers={}, **keyword_headers):
     assert destination is not None, "'destination' is required"
     assert body is not None, "'body' is required"
     headers = utils.merge_headers([headers, keyword_headers])
     headers[HDR_DESTINATION] = destination
     if content_type:
         headers[HDR_CONTENT_TYPE] = content_type
     body = encode(body)
     # if HDR_CONTENT_LENGTH not in headers:
     #    headers[HDR_CONTENT_LENGTH] = len(body)
     self.__send_frame(CMD_SEND, headers, body)
开发者ID:victoradan,项目名称:stomp.py,代码行数:11,代码来源:protocol.py

示例12: send

 def send(self, message='', headers={}, **keyword_headers):
     """
     Send a message (SEND) frame
     """
     if '\x00' in message:
         content_length_headers = {'content-length': len(message)}
     else:
         content_length_headers = {}
     self.__send_frame_helper('SEND', message, utils.merge_headers([headers, 
                                                                     keyword_headers,
                                                                     content_length_headers]), [ 'destination' ])
     self.__notify('send', headers, message)
开发者ID:TonyWildish,项目名称:DDM,代码行数:12,代码来源:connect.py

示例13: disconnect

 def disconnect(self, send_disconnect=True, headers={}, **keyword_headers):
     """
     Send a DISCONNECT frame to finish a connection
     """
     try:
         self.__send_frame_helper('DISCONNECT', '', utils.merge_headers([self.__connect_headers, headers, keyword_headers]), [ ])
     except exception.NotConnectedException:
         _, e, _ = sys.exc_info()
         self.disconnect_socket()
         raise e
     if self.version >= 1.1 and 'receipt' in headers:
         self.__disconnect_receipt = headers['receipt']
     else:
         self.disconnect_socket()
开发者ID:StratusLab,项目名称:client,代码行数:14,代码来源:connect.py

示例14: send

 def send(self, message='', headers={}, **keyword_headers):
     """
     Send a message (SEND) frame
     """
     merged_headers = utils.merge_headers([headers, keyword_headers])
     
     if self.__wait_on_receipt and 'receipt' in merged_headers.keys():
         self.__send_wait_condition.acquire()
      
     self.__send_frame_helper('SEND', message, merged_headers, [ 'destination' ])
     self.__notify('send', headers, message)
     
     # if we need to wait-on-receipt, then block until the receipt frame arrives 
     if self.__wait_on_receipt and 'receipt' in merged_headers.keys():
         receipt = merged_headers['receipt']
         while receipt not in self.__receipts:
             self.__send_wait_condition.wait()
         self.__send_wait_condition.release()
         del self.__receipts[receipt]
开发者ID:allenta,项目名称:splunk-stomp,代码行数:19,代码来源:connect.py

示例15: subscribe

 def subscribe(self, headers={}, **keyword_headers):
     """
     Send a SUBSCRIBE frame to subscribe to a queue
     """
     self.__send_frame_helper('SUBSCRIBE', '', utils.merge_headers([headers, keyword_headers]), [ 'destination' ])
开发者ID:TonyWildish,项目名称:DDM,代码行数:5,代码来源:connect.py


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