Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python3.8 aggr #4

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions examples/gevent_hello.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import gevent
import gevent.event as gevent_event

from haigha.connection import Connection as haigha_Connection
from haigha.message import Message
from haigha2.connection import Connection as haigha_Connection
from haigha2.message import Message


class HaighaGeventHello(object):
Expand Down Expand Up @@ -50,13 +50,13 @@ def __init__(self, done_cb):

# Publish a message on the channel
msg = Message('body', application_headers={'hello':'world'})
print "Publising message: %s" % (msg,)
print("Publising message: %s" % (msg,))
self._channel.basic.publish(msg, 'test_exchange', 'test_routing_key')
return


def _message_pump_greenthread(self):
print "Entering Message Pump"
print("Entering Message Pump")
try:
while self._conn is not None:
# Pump
Expand All @@ -65,15 +65,15 @@ def _message_pump_greenthread(self):
# Yield to other greenlets so they don't starve
gevent.sleep()
finally:
print "Leaving Message Pump"
print("Leaving Message Pump")
self._done_cb()
return


def _handle_incoming_messages(self, msg):
print
print "Received message: %s" % (msg,)
print
print()
print("Received message: %s" % (msg,))
print()

# Initiate graceful closing of the channel
self._channel.basic.cancel(consumer=self._handle_incoming_messages)
Expand All @@ -82,17 +82,17 @@ def _handle_incoming_messages(self, msg):


def _channel_closed_cb(self, ch):
print "AMQP channel closed; close-info: %s" % (
self._channel.close_info,)
print("AMQP channel closed; close-info: %s" % (
self._channel.close_info,))
self._channel = None

# Initiate graceful closing of the AMQP broker connection
self._conn.close()
return

def _connection_closed_cb(self):
print "AMQP broker connection closed; close-info: %s" % (
self._conn.close_info,)
print("AMQP broker connection closed; close-info: %s" % (
self._conn.close_info,))
self._conn = None
return

Expand All @@ -102,10 +102,10 @@ def main():

HaighaGeventHello(waiter.set)

print "Waiting for I/O to complete..."
print("Waiting for I/O to complete...")
waiter.wait()

print "Done!"
print("Done!")
return


Expand Down
10 changes: 5 additions & 5 deletions examples/rpc_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import sys, os, uuid, time
sys.path.append(os.path.abspath(".."))

from haigha.connection import Connection
from haigha.message import Message
from haigha2.connection import Connection
from haigha2.message import Message

class FibonacciRpcClient(object):
def __init__(self):
Expand All @@ -16,7 +16,7 @@ def __init__(self):

result = self.channel.queue.declare(exclusive=True)
self.callback_queue = result[0]
print("callback_queue:", self.callback_queue)
print(("callback_queue:", self.callback_queue))

self.channel.basic.consume(self.callback_queue, self.on_response, no_ack=True)

Expand All @@ -35,7 +35,7 @@ def call(self, n):

fibonacci_rpc = FibonacciRpcClient()

print " [x] Requesting fib(30)"
print(" [x] Requesting fib(30)")
response = fibonacci_rpc.call(30)
print " [.] Got %r" % (response,)
print(" [.] Got %r" % (response,))

8 changes: 4 additions & 4 deletions examples/rpc_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import sys, os, uuid, time
sys.path.append(os.path.abspath(".."))

from haigha.connection import Connection
from haigha.message import Message
from haigha2.connection import Connection
from haigha2.message import Message

connection = Connection(host='localhost', heartbeat=None, debug=True)
channel = connection.channel()
Expand All @@ -23,7 +23,7 @@ def fib(n):
def on_request(msg):
n = int(msg.body)

print " [.] fib(%s)" % (n,)
print(" [.] fib(%s)" % (n,))
result = fib(n)

reply_to = msg.properties["reply_to"]
Expand All @@ -37,7 +37,7 @@ def on_request(msg):
channel.basic.qos(prefetch_count=1)
channel.basic.consume('rpc_queue', on_request, no_ack=False)

print " [x] Awaiting RPC requests"
print(" [x] Awaiting RPC requests")
while not channel.closed:
connection.read_frames()

6 changes: 3 additions & 3 deletions examples/synchronous
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import random
import socket
from optparse import OptionParser

from haigha.connection import Connection
from haigha.message import Message
from haigha2.connection import Connection
from haigha2.message import Message

parser = OptionParser(
usage='Usage: synchronous_test [options]'
Expand All @@ -29,7 +29,7 @@ level = logging.DEBUG if debug else logging.INFO

# Setup logging
logging.basicConfig(level=level, format="[%(levelname)s %(asctime)s] %(message)s" )
logger = logging.getLogger('haigha')
logger = logging.getLogger('haigha2')

sock_opts = {
(socket.IPPROTO_TCP, socket.TCP_NODELAY) : 1,
Expand Down
6 changes: 3 additions & 3 deletions examples/synchronous_gevent
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import random
import socket
from optparse import OptionParser

from haigha.connection import Connection
from haigha.message import Message
from haigha2.connection import Connection
from haigha2.message import Message

parser = OptionParser(
usage='Usage: synchronous_test [options]'
Expand All @@ -29,7 +29,7 @@ level = logging.DEBUG if debug else logging.INFO

# Setup logging
logging.basicConfig(level=level, format="[%(levelname)s %(asctime)s] %(message)s" )
logger = logging.getLogger('haigha')
logger = logging.getLogger('haigha2')

sock_opts = {
(socket.IPPROTO_TCP, socket.TCP_NODELAY) : 1,
Expand Down
2 changes: 1 addition & 1 deletion haigha/__init__.py → haigha2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
https://github.com/agoragames/haigha/blob/master/LICENSE.txt
'''

__version__ = "0.9.0"
__version__ = "1.0.0"
16 changes: 8 additions & 8 deletions haigha/channel.py → haigha2/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

from collections import deque

from haigha.classes.protocol_class import ProtocolClass
from haigha.frames.frame import Frame
from haigha.frames.content_frame import ContentFrame
from haigha.frames.header_frame import HeaderFrame
from haigha.frames.method_frame import MethodFrame
from haigha.exceptions import ChannelError, ChannelClosed, ConnectionClosed
from haigha2.classes.protocol_class import ProtocolClass
from haigha2.frames.frame import Frame
from haigha2.frames.content_frame import ContentFrame
from haigha2.frames.header_frame import HeaderFrame
from haigha2.frames.method_frame import MethodFrame
from haigha2.exceptions import ChannelError, ChannelClosed, ConnectionClosed

# Defined here so it's easier to test

Expand Down Expand Up @@ -62,7 +62,7 @@ def __init__(self, connection, channel_id, class_map, **kwargs):
self._logger = connection.logger

self._class_map = {}
for _id, _class in class_map.iteritems():
for _id, _class in class_map.items():
impl = _class(self)
setattr(self, impl.name, impl)
self._class_map[_id] = impl
Expand Down Expand Up @@ -413,7 +413,7 @@ def _closed_cb(self, final_frame=None):
self._frame_buffer = deque()

# clear out other references for faster cleanup
for protocol_class in self._class_map.values():
for protocol_class in list(self._class_map.values()):
protocol_class._cleanup()
delattr(self, protocol_class.name)
self._connection = None
Expand Down
File renamed without changes.
File renamed without changes.
16 changes: 8 additions & 8 deletions haigha/classes/basic_class.py → haigha2/classes/basic_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

from collections import deque

from haigha.message import Message
from haigha.writer import Writer
from haigha.frames.method_frame import MethodFrame
from haigha.frames.header_frame import HeaderFrame
from haigha.frames.content_frame import ContentFrame
from haigha.classes.protocol_class import ProtocolClass
from haigha2.message import Message
from haigha2.writer import Writer
from haigha2.frames.method_frame import MethodFrame
from haigha2.frames.header_frame import HeaderFrame
from haigha2.frames.content_frame import ContentFrame
from haigha2.classes.protocol_class import ProtocolClass


class BasicClass(ProtocolClass):
Expand Down Expand Up @@ -186,7 +186,7 @@ def _lookup_consumer_tag_by_consumer(self, consumer):
:returns: matching consumer tag or None
:rtype: str or None
'''
for (tag, func) in self._consumer_cb.iteritems():
for (tag, func) in self._consumer_cb.items():
if func == consumer:
return tag

Expand Down Expand Up @@ -449,4 +449,4 @@ def _reap_msg_frames(self, method_frame):
self.channel.requeue_frames([method_frame])
raise self.FrameUnderflow()

return (header_frame, body)
return header_frame, body
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
https://github.com/agoragames/haigha/blob/master/LICENSE.txt
'''

from haigha.classes.protocol_class import ProtocolClass
from haigha.frames.method_frame import MethodFrame
from haigha.writer import Writer
from haigha2.classes.protocol_class import ProtocolClass
from haigha2.frames.method_frame import MethodFrame
from haigha2.writer import Writer


class ChannelClass(ProtocolClass):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

from collections import deque

from haigha.writer import Writer
from haigha.frames.method_frame import MethodFrame
from haigha.classes.protocol_class import ProtocolClass
from haigha2.writer import Writer
from haigha2.frames.method_frame import MethodFrame
from haigha2.classes.protocol_class import ProtocolClass


class ExchangeClass(ProtocolClass):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
https://github.com/agoragames/haigha/blob/master/LICENSE.txt
'''

from haigha.writer import Writer
from haigha.frames.method_frame import MethodFrame
from haigha.classes.protocol_class import ProtocolClass
from haigha2.writer import Writer
from haigha2.frames.method_frame import MethodFrame
from haigha2.classes.protocol_class import ProtocolClass

from collections import deque

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
https://github.com/agoragames/haigha/blob/master/LICENSE.txt
'''

from haigha.frames.method_frame import MethodFrame
from haigha.classes.protocol_class import ProtocolClass
from haigha2.frames.method_frame import MethodFrame
from haigha2.classes.protocol_class import ProtocolClass

from collections import deque

Expand Down
44 changes: 22 additions & 22 deletions haigha/connection.py → haigha2/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
https://github.com/agoragames/haigha/blob/master/LICENSE.txt
'''

from haigha.channel import Channel
from haigha.frames.frame import Frame
from haigha.frames.heartbeat_frame import HeartbeatFrame
from haigha.frames.method_frame import MethodFrame
from haigha.classes.basic_class import BasicClass
from haigha.classes.channel_class import ChannelClass
from haigha.classes.exchange_class import ExchangeClass
from haigha.classes.queue_class import QueueClass
from haigha.classes.transaction_class import TransactionClass
from haigha.writer import Writer
from haigha.reader import Reader
from haigha.transports.transport import Transport
from exceptions import ConnectionError, ConnectionClosed

import haigha
from haigha2.channel import Channel
from haigha2.frames.frame import Frame
from haigha2.frames.heartbeat_frame import HeartbeatFrame
from haigha2.frames.method_frame import MethodFrame
from haigha2.classes.basic_class import BasicClass
from haigha2.classes.channel_class import ChannelClass
from haigha2.classes.exchange_class import ExchangeClass
from haigha2.classes.queue_class import QueueClass
from haigha2.classes.transaction_class import TransactionClass
from haigha2.writer import Writer
from haigha2.reader import Reader
from haigha2.transports.transport import Transport
from .exceptions import ConnectionError, ConnectionClosed

import haigha2
import time

from logging import root as root_logger
Expand All @@ -29,12 +29,12 @@
# AMQP0091 = 0-9-1
# http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/2010-July/008231.html
# PROTOCOL_HEADER = 'AMQP\x01\x01\x09\x01'
PROTOCOL_HEADER = 'AMQP\x00\x00\x09\x01'
PROTOCOL_HEADER = b'AMQP\x00\x00\x09\x01'

# Client property info that gets sent to the server on connection startup
LIBRARY_PROPERTIES = {
'library': 'Haigha',
'library_version': haigha.__version__,
'library_version': haigha2.__version__,
}


Expand All @@ -52,7 +52,7 @@ def __init__(self, **kwargs):
'''
Initialize the connection.
'''
self._debug = kwargs.get('debug', False)
self._debug = kwargs.get('debug', 0)
self._logger = kwargs.get('logger', root_logger)

self._user = kwargs.get('user', 'guest')
Expand Down Expand Up @@ -118,17 +118,17 @@ def __init__(self, **kwargs):
transport = kwargs.get('transport', 'socket')
if not isinstance(transport, Transport):
if transport == 'event':
from haigha.transports.event_transport import EventTransport
from haigha2.transports.event_transport import EventTransport
self._transport = EventTransport(self)
elif transport == 'gevent':
from haigha.transports.gevent_transport import GeventTransport
from haigha2.transports.gevent_transport import GeventTransport
self._transport = GeventTransport(self)
elif transport == 'gevent_pool':
from haigha.transports.gevent_transport import \
from haigha2.transports.gevent_transport import \
GeventPoolTransport
self._transport = GeventPoolTransport(self, **kwargs)
elif transport == 'socket':
from haigha.transports.socket_transport import SocketTransport
from haigha2.transports.socket_transport import SocketTransport
self._transport = SocketTransport(self)
else:
self._transport = transport
Expand Down
File renamed without changes.
Loading