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

Event Listener #3

Closed
vrbrito opened this issue Apr 16, 2019 · 5 comments
Closed

Event Listener #3

vrbrito opened this issue Apr 16, 2019 · 5 comments

Comments

@vrbrito
Copy link

vrbrito commented Apr 16, 2019

Hello,

Could you help me to access the event listener using hueyx?

On native HUEY, I would have:

HUEY = RedisHuey('general', always_eager=False)

pubsub = settings.HUEY.storage.listener()

        for message in pubsub.listen():

                 ...

For the analogue HUEYX definition:

HUEYX = {'general': {
            'connection': {'connection_pool': ConnectionPool(host='localhost', port=6379, db=0)},
            'consumer': {'workers': 1, 'worker_type': 'thread'},
            'always_eager': False
        },
        'monitors': {
            'connection': {'connection_pool': ConnectionPool(host='localhost', port=6379, db=1, max_connections=20)},
            'consumer': {'workers': 10,'worker_type': 'thread'},
            'always_eager': False,
        },
}

How could I access the event listener?

Thank you in advance.

@SeverinAlexB
Copy link
Contributor

SeverinAlexB commented Apr 16, 2019

You get your huey instance by

from hueyx.queues import hueyx

HUEY_GENERAL = hueyx('general')
HUEY_MONITORS = hueyx('monitors')

Then you should access the storage by

storage = HUEY_GENERAL.storage

See https://huey.readthedocs.io/en/1.11.0/events.html#listening-to-events

Be aware, the huey base package replaced the event system by a signal system. Chances are that your code above is already deprecated. Hueyx itself is not tested yet with huey 2.0. See #4 .

@vrbrito
Copy link
Author

vrbrito commented Apr 16, 2019

Do you know how to combine both storages on a single listener?

@SeverinAlexB
Copy link
Contributor

With a hack yes. Have a look at the huey exporter
https://github.com/APGSGA/huey-exporter/blob/master/huey_exporter/EventListener.py#L102

It provides Prometheus metrics and explores/subscribes queues automatically.

@vrbrito
Copy link
Author

vrbrito commented Apr 16, 2019

Thank you very much, @Sebubu

@SeverinAlexB
Copy link
Contributor

SeverinAlexB commented Aug 5, 2019

Hueyx 1.0.0 has been released. The signal system is now supported.

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

No branches or pull requests

2 participants