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

Support for on_shutdown events #9

Open
rgrm opened this issue Aug 10, 2020 · 1 comment
Open

Support for on_shutdown events #9

rgrm opened this issue Aug 10, 2020 · 1 comment

Comments

@rgrm
Copy link

rgrm commented Aug 10, 2020

Hi,

I am not quite sure where to put the comment. hence raising it as issue.

Is there way to add support to on_shutdown event ?

My problem statement.. I have 3 different consumers but I would like to get all of their logs into one single LOG FILE with rotation handler .. Unfortunately Python logging doesn't support logging into same file from multiple process and hence it hits permission denied error. So, the recommendation by most folks is about using socket handler for streaming logs from all processes into master process and storing then to a file..

So, I am running a socket server on the a master process and that will run as soon as my consumers starts.. But, on consumer shutdown I would like to gracefully stop a socket server that I am starting as part of a task.

I looked at on_shutdown event from huey but unfortunately that doesn't seems to be helping with hueyx.

from huey.contrib.djhuey import on_shutdown

@on_shutdown()
def on_consumers_going_down():
    print("They are going down")
@zyrif
Copy link

zyrif commented Sep 9, 2020

@rgrm There's already support for on_shutdown hook, you need to register it like this:

from hueyx.queues import hueyx
HUEY_Q1 = hueyx('queue_name1')

@HUEY_Q1.on_shutdown()
def huey_shutdown_tasks():
    pass

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