Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
contego / home / tvault / .virtenv / lib / python2.7 / site-packages / kombu / messaging.pyc
Size: Mime:
ó
öEYc@@s*dZddlmZmZddlmZddlmZddlm	Z	ddl
mZmZddl
mZmZmZdd	lmZdd
lmZmZmZmZddlmZmZddlmZmZd
dddgZedefd„ƒYƒZ edefd„ƒYƒZ!dS(uSending and receiving messages.i(tabsolute_importtunicode_literals(tcounti(t
maybe_declare(tcompress(t
maybe_channelt
is_connection(tExchangetQueuetmaybe_delivery_mode(tContentDisallowed(titemstpython_2_unicode_compatiblettext_ttvalues(tdumpstprepare_accept_content(tChannelPromiset
maybe_listuExchangeuQueueuProduceruConsumertProducercB@sFeZdZdZdZdZdZeZ	dZ
dZddddddd„Zd„Z
d„Zd„Zd„Zed„Zdeed„Zddeed	ddddddedddd
„Zd„Zd„Zd
„ZeeeƒZd„Zd„Zd„Zd„ZeZ dddddd„Z!ed„ƒZ"RS(ueMessage Producer.

    Arguments:
        channel (kombu.Connection, ChannelT): Connection or channel.
        exchange (Exchange, str): Optional default exchange.
        routing_key (str): Optional default routing key.
        serializer (str): Default serializer. Default is `"json"`.
        compression (str): Default compression method.
            Default is no compression.
        auto_declare (bool): Automatically declare the default exchange
            at instantiation. Default is :const:`True`.
        on_return (Callable): Callback to call for undeliverable messages,
            when the `mandatory` or `immediate` arguments to
            :meth:`publish` is used. This callback needs the following
            signature: `(exception, exchange, routing_key, message)`.
            Note that the producer needs to drain events to use this feature.
    ucC@s¼||_||_|p|j|_|p0|j|_|pB|j|_|pT|j|_d|_|jdkr„tdƒ|_n|dk	rœ||_	n|jr¸|j
|jƒndS(Nu(t_channeltexchangetrouting_keyt
serializertcompressiont	on_returntNonet_channel_promiseRtauto_declaretrevive(tselftchannelRRRRRR((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyt__init__=s				cC@s
dj|ƒS(Nu<Producer: {0._channel}>(tformat(R((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyt__repr__OscC@s|j|jƒfS(N(t	__class__t__reduce_args__(R((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyt
__reduce__RscC@s%d|j|j|j|j|jfS(N(RRRRRR(R((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyR$UscC@s |jjr|jjƒndS(u Declare the exchange.

        Note:
            This happens automatically at instantiation when
            the :attr:`auto_declare` flag is enabled.
        N(Rtnametdeclare(R((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyR'YscK@s |rt||j||SdS(u=Declare exchange if not already declared during this session.N(RR(Rtentitytretrytretry_policy((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyRcscC@sGt||ƒr+|j||p$|jƒfS|||p@|jjƒfS(N(t
isinstanceR&t
delivery_modeR(RRR,R	R((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyt_delivery_detailshs
	icK@s|j}|dkrgn|}|
dkr3in|
}
|dkrKin|}|dkrf|jn|}|dkr|jn|}|j|p™|j|ƒ\}|d<|dk	rÕtt|dƒƒ|d<n|j||	||||
ƒ\}}}|j	r6|jj
r6|j|kr6|j|jƒq6n|
rW|jj
|||}n||||||
||||||ƒS(uhPublish message to the specified exchange.

        Arguments:
            body (Any): Message body.
            routing_key (str): Message routing key.
            delivery_mode (enum): See :attr:`delivery_mode`.
            mandatory (bool): Currently not supported.
            immediate (bool): Currently not supported.
            priority (int): Message priority. A number between 0 and 9.
            content_type (str): Content type. Default is auto-detect.
            content_encoding (str): Content encoding. Default is auto-detect.
            serializer (str): Serializer to use. Default is auto-detect.
            compression (str): Compression method to use.  Default is none.
            headers (Dict): Mapping of arbitrary headers to pass along
                with the message body.
            exchange (Exchange, str): Override the exchange.
                Note that this exchange must have been declared.
            declare (Sequence[EntityT]): Optional list of required entities
                that must have been declared before publishing the message.
                The entities will be declared using
                :func:`~kombu.common.maybe_declare`.
            retry (bool): Retry publishing, or declaring entities if the
                connection is lost.
            retry_policy (Dict): Retry configuration, this is the keywords
                supported by :meth:`~kombu.Connection.ensure`.
            expiration (float): A TTL in seconds can be specified per message.
                Default is no expiration.
            **properties (Any): Additional message properties, see AMQP spec.
        u
delivery_modeièu
expirationN(t_publishRRRR-Rtstrtintt_prepareRR&tappendt
connectiontensure(RtbodyRR,t	mandatoryt	immediatetprioritytcontent_typetcontent_encodingRtheadersRRR)R*R't
expirationt
propertiesR.t
exchange_name((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pytpublishus,#	c
C@s©|j}|j||||||ƒ}
|rV|j}g|D]}||ƒ^q=n|jdƒ}t|tƒr„|j|d<n|j|
d|
d|d|d|	ƒS(Nureply_toRRR6R7(Rtprepare_messageRtgetR+RR&t
basic_publish(RR5R8R9R:R;R=RR6R7RR'RtmessageRR(treply_to((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyR.¸s			 cC@sb|j}t|tƒr^|ƒ}|_|jj|ƒ|jr^|jdj|jƒq^n|S(Nubasic_return(RR+RRRRteventstadd(RR((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyt_get_channelÎs		cC@s
||_dS(N(R(RR((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyt_set_channel×sc@s¥t|ƒr3|‰ˆ|_t‡fd†ƒ}nt|tƒr`||_|j|ƒ|_nA||_|jr|jjdj|jƒn|j|ƒ|_dS(u*Revive the producer after connection loss.c@sˆjS(N(tdefault_channel((R3(sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyt<lambda>àsubasic_returnN(	Rt__connection__RR+RRRRERF(RR((R3sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyRÛs				cC@s|S(N((R((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyt	__enter__ëscG@s|jƒdS(N(trelease(Rtexc_info((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyt__exit__îscC@sdS(N((R((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyRMñscC@s¡|s3|p|j}t|d|ƒ\}}}n?t|tƒrc|sQd}n|j|ƒ}n|srd}n|r”t||ƒ\}|d<n|||fS(NRuutf-8ubinaryucompression(RRR+R
tencodeR(RR5RR9R:RR;((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyR1õs		cC@s2y|jp|jjjSWntk
r-nXdS(N(RKRR3tclienttAttributeError(R((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyR3s
N(#t__name__t
__module__t__doc__RRRRRtTrueRRRKR R"R%R$R'tFalseRR	RR-R?R.RGRHtpropertyRRRLRORMtcloseR1R3(((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyRsH					
		?								tConsumerc
B@s|eZdZeZdZdZdZeZ	dZ
dZdZdZ
dZdZedƒZdddddddddd„	Zed„ƒZejd„ƒZd„Zd„Zd„Zd„Zd	„Zd
„Zdd„Zd„ZeZd
„Zd„Zd„Z d„Z!dde"d„Z#e"d„Z$d„Z%deed„Z&dd„Z'd„Z(d„Z)ed„ƒZ*RS(uöMessage consumer.

    Arguments:
        channel (kombu.Connection, ChannelT): see :attr:`channel`.
        queues (Sequence[kombu.Queue]): see :attr:`queues`.
        no_ack (bool): see :attr:`no_ack`.
        auto_declare (bool): see :attr:`auto_declare`
        callbacks (Sequence[Callable]): see :attr:`callbacks`.
        on_message (Callable): See :attr:`on_message`
        on_decode_error (Callable): see :attr:`on_decode_error`.
        prefetch_count (int): see :attr:`prefetch_count`.
    icC@sã||_t|pgƒ|_|dkr3|jn||_|dkrW|jpZgn||_||_|
|_i|_|dk	r“||_	n|dk	r«||_
nt|ƒ|_|	|_
|jrß|j|jƒndS(N(RRtqueuesRtno_ackt	callbackst
on_messaget
tag_prefixt_active_tagsRton_decode_errorRtaccepttprefetch_countR(RRR[R\RR]RaR^RbRcR_((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyR os 							cC@st|jjƒƒS(N(tlistt_queuesR(R((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyR[„scC@sd„|Dƒ|_dS(NcS@si|]}||j“qS((R&(t.0tq((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pys
<dictcomp>Šs	(Re(RR[((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyR[ˆscC@s¼|jjƒt|ƒ}|_xZt|jƒD]I\}}|jj|dƒ||jƒ}|j|j<|j	|ƒq0W|j
r“|jƒn|jdk	r¸|j
d|jƒndS(u&Revive consumer after connection loss.RcN(R`tclearRRRRetpopRR&RRR'Rctqos(RRtqnametqueue((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyRŒs
	
cC@s(x!t|jƒD]}|jƒqWdS(u¥Declare queues, exchanges and bindings.

        Note:
            This is done automatically at instantiation
            when :attr:`auto_declare` is set.
        N(RReR'(RRl((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyR'œscC@s|jj|ƒdS(uRegister a new callback to be called when a message is received.

        Note:
            The signature of the callback needs to accept two arguments:
            `(body, message)`, which is the decoded message body
            and the :class:`~kombu.Message` instance.
        N(R]R2(Rtcallback((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pytregister_callback¦scC@s|jƒ|S(N(tconsume(R((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyRL°s
cC@sV|jrR|jjjj}t||ƒsRy|jƒWqOtk
rKqOXqRndS(N(RR3RQtconnection_errorsR+tcancelt	Exception(Rtexc_typetexc_valtexc_tbtconn_errors((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyRO´s	
cC@s9||jƒ}|jr%|jƒn||j|j<|S(uÆAdd a queue to the list of queues to consume from.

        Note:
            This will not start consuming from the queue,
            for that you will have to call :meth:`consume` after.
        (RRR'ReR&(RRl((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyt	add_queue½s
	
cC@s•tt|jƒƒ}|r‘|dkr0|jn|}|d |d}}x'|D]}|j|d|dtƒqRW|j|d|dtƒndS(uDStart consuming messages.

        Can be called multiple times, but note that while it
        will consume from new queues added since the last call,
        it will not cancel consuming from removed queues (
        use :meth:`cancel_by_queue`).

        Arguments:
            no_ack (bool): See :attr:`no_ack`.
        iÿÿÿÿR\tnowaitN(RdRReRR\t_basic_consumeRVRW(RR\R[tHtTRl((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyRoÊs
cC@sA|jj}x!t|jƒD]}||ƒqW|jjƒdS(uÏEnd all active queue consumers.

        Note:
            This does not affect already delivered messages, but it does
            mean the server will not send any more messages for this consumer.
        N(Rtbasic_cancelRR`Rh(RRqttag((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyRqÞscC@swt|tƒr|jn|}z>y|jj|ƒ}Wntk
rJnX|jj|ƒWd|jj|dƒXdS(uCancel consumer by queue name.N(
R+RR&R`RitKeyErrorRR|ReR(RRlRkR}((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pytcancel_by_queueës
cC@s.|}t|tƒr!|j}n||jkS(u8Return :const:`True` if currently consuming from queue'.(R+RR&R`(RRlR&((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pytconsuming_from÷scC@std„t|jƒDƒƒS(u‰Purge messages from all queues.

        Warning:
            This will *delete all ready messages*, there is no undo operation.
        cs@s|]}|jƒVqdS(N(tpurge(RfRl((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pys	<genexpr>s(tsumRRe(R((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyRþscC@s|jj|ƒdS(u’Enable/disable flow from peer.

        This is a simple flow-control mechanism that a peer can use
        to avoid overflowing its queues or otherwise finding itself
        receiving more messages than it can process.

        The peer that receives a request to stop sending content
        will finish sending the current content (if any), and then wait
        until flow is reactivated.
        N(Rtflow(Rtactive((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyRƒsicC@s|jj|||ƒS(uSpecify quality of service.

        The client can request that messages should be sent in
        advance so that when the client finishes processing a message,
        the following message is already held locally, rather than needing
        to be sent down the channel. Prefetching gives a performance
        improvement.

        The prefetch window is Ignored if the :attr:`no_ack` option is set.

        Arguments:
            prefetch_size (int): Specify the prefetch window in octets.
                The server will send a message in advance if it is equal to
                or smaller in size than the available prefetch size (and
                also falls within other prefetch limits). May be set to zero,
                meaning "no specific limit", although other prefetch limits
                may still apply.

            prefetch_count (int): Specify the prefetch window in terms of
                whole messages.

            apply_global (bool): Apply new settings globally on all channels.
        (Rt	basic_qos(Rt
prefetch_sizeRctapply_global((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyRjscC@s|jjd|ƒS(u¿Redeliver unacknowledged messages.

        Asks the broker to redeliver all unacknowledged messages
        on the specified channel.

        Arguments:
            requeue (bool): By default the messages will be redelivered
                to the original recipient. With `requeue` set to true, the
                server will attempt to requeue the message, potentially then
                delivering it to an alternative subscriber.
        trequeue(Rt
basic_recover(RRˆ((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pytrecover/scC@sB|j}|stdƒ‚ng|D]}|||ƒ^q%dS(ucMethod called when a message is received.

        This dispatches to the registered :attr:`callbacks`.

        Arguments:
            body (Any): The decoded message body.
            message (~kombu.Message): The message instance.

        Raises:
            NotImplementedError: If no consumer callbacks have been
                registered.
        u$Consumer does not have any callbacksN(R]tNotImplementedError(RR5RCR]Rm((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pytreceive=s
	cC@sY|jj|jƒ}|dkrU|j||ƒ}|j||jd|d|ƒn|S(NR\Rx(R`RAR&Rt_add_tagRot_receive_callback(RRltconsumer_tagR\RxR}((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyRyOscC@s8|p!dj|jt|jƒƒ}||j|j<|S(Nu{0}{1}(R!R_tnextt_tagsR`R&(RRlRR}((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyRXscC@sð|j}|j|jd}}}ytt|ddƒ}|rM||ƒ}n|dk	re||_n|jr~|j|jƒS|rŠdn	|jƒ}Wn2t	k
rË}|js¸‚n|j||ƒn!X|rÜ||ƒS|j
||ƒSdS(Numessage_to_python(RbR^RRtgetattrterrorst_reraise_errorRatdecodeRrRŒ(RRCRbton_mRtdecodedtm2ptexc((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyRŽ^s 			cC@sdj|dt|ƒjƒS(Nu<{name}: {0.queues}>R&(R!ttypeRS(R((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyR"qscC@s)y|jjjSWntk
r$nXdS(N(RR3RQRR(R((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyR3ts
N(+RSRTRUR
RRR[R\RVRR]R^RaRbRcReRR‘R RXtsetterRR'RnRLRORwRoRqRYRR€RRƒRWRjRŠRŒRyRRŽR"R3(((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyRZsP
					
	
				
					
			N("RUt
__future__RRt	itertoolsRtcommonRRRR3RRR(RRR	t
exceptionsR
tfiveRRR
Rt
serializationRRtutils.functionalRRt__all__tobjectRRZ(((sD/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/messaging.pyt<module>s "ÿ