Skip to content

Commit

Permalink
Merge branch 'issue_1131-pika'
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdvegas committed Oct 19, 2021
2 parents 52bf6a3 + f2f1ea5 commit 075ba70
Show file tree
Hide file tree
Showing 30 changed files with 16,416 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/rez/utils/_version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@


# Update this value to version up Rez. Do not place anything else in this file.
_rez_version = "2.95.3"
_rez_version = "2.96.0"


# Copyright 2013-2016 Allan Johns.
Expand Down
52 changes: 29 additions & 23 deletions src/rez/utils/amqp.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
import threading

from rez.utils import json
from rez.utils.data_utils import remove_nones
from rez.utils.logging_ import print_error
from rez.vendor.amqp import Connection, basic_message
from rez.vendor.six.six.moves import queue
from rez.vendor.pika.adapters.blocking_connection import BlockingConnection
from rez.vendor.pika.connection import ConnectionParameters
from rez.vendor.pika.credentials import PlainCredentials
from rez.vendor.pika.spec import BasicProperties


_lock = threading.Lock()
Expand Down Expand Up @@ -59,33 +61,37 @@ def _publish_message(host, amqp_settings, routing_key, data):
print("Published to %s: %s" % (routing_key, data))
return True

try:
conn = Connection(**remove_nones(
host=host,
userid=amqp_settings.get("userid"),
password=amqp_settings.get("password"),
connect_timeout=amqp_settings.get("connect_timeout")
))
except socket.error as e:
print_error("Cannot connect to the message broker: %s" % (e))
return False
creds = PlainCredentials(
username=amqp_settings.get("userid"),
password=amqp_settings.get("password")
)

channel = conn.channel()
params = ConnectionParameters(
host=host,
credentials=creds,
socket_timeout=amqp_settings.get("connect_timeout")
)

# build the message
msg = basic_message.Message(**remove_nones(
body=json.dumps(data),
delivery_mode=amqp_settings.get("message_delivery_mode"),
props = BasicProperties(
content_type="application/json",
content_encoding="utf-8"
))
content_encoding="utf-8",
delivery_mode=amqp_settings.get("message_delivery_mode")
)

try:
conn = BlockingConnection(params)
except socket.error as e:
print_error("Cannot connect to the message broker: %s" % e)
return False

# publish the message
try:
channel = conn.channel()

channel.basic_publish(
msg,
amqp_settings["exchange_name"],
routing_key
exchange=amqp_settings["exchange_name"],
routing_key=routing_key,
body=json.dumps(data),
properties=props
)
except Exception as e:
print_error("Failed to publish message: %s" % (e))
Expand Down
25 changes: 25 additions & 0 deletions src/rez/vendor/pika/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Copyright (c) 2009-2019, Tony Garnock-Jones, Gavin M. Roy, Pivotal Software, Inc and others.
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the Pika project nor the names of its contributors may be used
to endorse or promote products derived from this software without specific
prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6 changes: 6 additions & 0 deletions src/rez/vendor/pika/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
__version__ = '1.2.0'

import logging

# Add NullHandler before importing Pika modules to prevent logging warnings
logging.getLogger(__name__).addHandler(logging.NullHandler())
23 changes: 23 additions & 0 deletions src/rez/vendor/pika/adapters/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""
Connection Adapters
===================
Pika provides multiple adapters to connect to RabbitMQ:
- adapters.asyncio_connection.AsyncioConnection: Native Python3 AsyncIO use
- adapters.blocking_connection.BlockingConnection: Enables blocking,
synchronous operation on top of library for simple uses.
- adapters.gevent_connection.GeventConnection: Connection adapter for use with
Gevent.
- adapters.select_connection.SelectConnection: A native event based connection
adapter that implements select, kqueue, poll and epoll.
- adapters.tornado_connection.TornadoConnection: Connection adapter for use
with the Tornado web framework.
- adapters.twisted_connection.TwistedProtocolConnection: Connection adapter for
use with the Twisted framework
"""
from rez.vendor.pika.adapters.base_connection import BaseConnection
from rez.vendor.pika.adapters.blocking_connection import BlockingConnection
from rez.vendor.pika.adapters.select_connection import SelectConnection
from rez.vendor.pika.adapters.select_connection import IOLoop
Loading

0 comments on commit 075ba70

Please sign in to comment.