Skip to content

Conversation

@lbt
Copy link
Member

@lbt lbt commented Apr 30, 2021

Convert to python3
Use Pika
Use proper packaging
Support cancel and stop

lbt and others added 13 commits February 28, 2019 17:30
Signed-off-by: David Greaves <david.greaves@jolla.com>
Signed-off-by: David Greaves <david.greaves@jolla.com>
Signed-off-by: David Greaves <david.greaves@jolla.com>
Signed-off-by: David Greaves <david.greaves@jolla.com>
Signed-off-by: David Greaves <david.greaves@jolla.com>
Make stacktrace more visible in errors

Signed-off-by: David Greaves <david.greaves@jolla.com>
Signed-off-by: David Greaves <david.greaves@jolla.com>
Signed-off-by: David Greaves <david.greaves@jolla.com>
Signed-off-by: David Greaves <david.greaves@jolla.com>
Signed-off-by: David Greaves <david.greaves@jolla.com>
Signed-off-by: David Greaves <david.greaves@jolla.com>
finish() should be called to cleanly exit by invoking stop()

Signed-off-by: David Greaves <david.greaves@jolla.com>
Signed-off-by: David Greaves <david.greaves@jolla.com>
password=self.pw,
virtual_host=self.vhost,
insist=False)
self._conn_params = dict(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could just create pika.ConnectionParameters object here, instead of putting them in separate dict that is then just expanded with **

from amqplib import client_0_8 as amqp
import pika

try:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This try/except is not needed... remnants from python 2.5 times :) And other places using json seem to have similar pattern

import logging
import time

logging.basicConfig(format='%(asctime)s %(name)s %(levelname)s: %(message)s',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This maybe shouldn't be doing global logging configuration. It's more responsibility of what ever is using the library. Not related to your changes, but just caught my eye.

self.__participant.consume(self.workitem)
except Exception as exobj:
# This should be configureable:
self.log.error("Exception in participant %s\n"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use log.exception(...) here and remove the traceback formatting below

try:
return self._h['participant_name']
except:
except IndexError:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be KeyError?

BuildArch: noarch
Vendor: David Greaves <david.greaves@jollamobile.com>
Url: http://github.com/MeegoIntegration/python-ruote-amqp

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be Requires: python3-pika?

"""
Closes channel and connection
Call finish() to close the channel and connection and exit cleanly.
This invokes the die() callback which can be overridden to clean up.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stop() instead of die()

"""
tag = msg.delivery_info["delivery_tag"]
tag = method.delivery_tag
self._consumer_tag = method.consumer_tag
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _consumer_tag should probably be taken from the return value of _channel.basic_consume(), so that it is available if finish() called before any messages have arrived

self.workitem.wfid,
self.workitem.wf_name))
self.log.error(format_block(traceback.format_exc()))
self.exception = exobj
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't seem to be necessary to store references to the exception and trace in this thread object anymore, as the error processing is done here (earlier it was on the Participant class side)

if self.params.forget:
return True
except:
except Exception:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.params is a DictAttrProxy, so params.forget would be None if 'forget' is not in the params dict... I'm not sure what kind of exception this could throw, so the whole try/except seem unnecessary

lbt added 9 commits October 13, 2021 14:03
Signed-off-by: David Greaves <david@dgreaves.com>
Signed-off-by: David Greaves <david@dgreaves.com>
Signed-off-by: David Greaves <david@dgreaves.com>
Signed-off-by: David Greaves <david@dgreaves.com>
Signed-off-by: David Greaves <david@dgreaves.com>
Signed-off-by: David Greaves <david@dgreaves.com>
Signed-off-by: David Greaves <david@dgreaves.com>
Signed-off-by: David Greaves <david.greaves@jolla.com>
Allow:
* setting via [] with __setitem__
* creation by passing a dict which is wrapped (not copied)
* pretty __str__ and __unicode__ handlers

Signed-off-by: David Greaves <david.greaves@jolla.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants