-
Notifications
You must be signed in to change notification settings - Fork 16
Run listeners using subprocess running in background #647
base: master
Are you sure you want to change the base?
Conversation
related change: Kinto/kinto#435 |
workaround for pypy, see uqfoundation/dill#73 |
c1d3457
to
06f88ea
Compare
Signals will be in their own PR #648 |
I don't like to start discussion like that when code is already written and I really would like this kind of implementation to start with an article that explain the rationale. I may have missed the discussion around that though. What I understood of our plan is defined here: http://www.servicedenuages.fr/en/notifications-kinto-preamble It was the outcome of a really long discussion we had in Douarnenez about how to handle notifications. I am not really fond of the idea of spawning process from the web server. This means that each wsgi worker will have its own pool of memory workers:
The plan we had in mind was to use Redis to add tasks to a queue and then have worker that will consume this queue. If I understand correctly, your plan with this code is to feed the Redis queue with async calls made by your worker. The way it works currently is IMO much simpler because a worker is always handling a request or triggering a notification. If we make sure that the notification handling happens after the response was sent back to the user then we can be confident that it will handle the notification asynchronously before the worker taking another request. Because we are using uwsgi if a request arrive in the mean time another web worker will be spawn so that the notification task(s) will not block other requests. Am I missing the point? |
Background Processes | ||
==================== | ||
|
||
Cliquet uses a pool of processes to run some background processes to avoif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid
(?) Quickly, some related discussions: |
As an irregular contributor, I have initiated some discussions and opened a bunch of issues here and there to make sure I was doing everything right and I have discussed the rationale with @leplatrem several times. I am happy to explain thing to @Natim but I am not going to continue working on this feature: getting back a feedback where my PR is rejected because I did not write an article about it is a very negative signal - it does not make me want to contribute code to the project - we should make sure this does not happen for contributors. If it's mandatory to write an article prior to a change, please make it clear in the contributing document. (and write an article about this change before?? :) . FWIW I think it's a weird process. We should write articles on new features we added in Kinto. Feedback on design should be done in an interactive system that's meant for it: the issue tracker . Feedback on code should be done in the PRs. |
I agree with you that it should not be mandatory to write an article prior to any change in the code base. You apparently had this discussion last week and I missed it. Your concerns about listener code taking time during a notification is really a good point and we should fix that. We can see for instance that activating I am sorry if my comment made you think you should close your pull-request, it wasn't meant to be. We need to fix that and your pull-request aims to do so. I was just asking myself out-loud if handling workers in the WSGI worker was the right solution and maybe it is. I would love to discuss this next week so that we can agree on the solution to fix the issue you are pointing out. |
5c8fa56
to
db05c66
Compare
So I believe the plan was to land this as-is, with minor tweaks, but I do not remember exactly what. @leplatrem @Natim can you add some more info here? |
As far as I understood the idea was to mark listener as async or sync in the configuration and being able to select the async backend we'd like to use to queue using this In the future other async queing system such as Celery or rq could also be plugged as async listener. @leplatrem is that what you had in mind too? |
My ideas:
|
Just async onces maybe. This should be configurable at the listener configuration level.
I would rather go for default Also it is always a good question to ask yourself if the notification should be async or sync and if you want a failing notification to break the transaction or not. In the case of OneCRL if we cannot send a mail, do we want to mark the collection in a review state while nobody was notified? |
c67580b
to
5c93e04
Compare
|
This pull request adds the following: