-
Notifications
You must be signed in to change notification settings - Fork 21
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
feat: utility to reset application state before processing event #277
feat: utility to reset application state before processing event #277
Conversation
Thanks for the pull request, @navinkarkera! Please note that it may take us up to several weeks or months to complete a review and merge your PR. Feel free to add as much of the following information to the ticket as you can:
All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here. Please let us know once your PR is ready for our review and all tests are green. |
openedx_events/tooling.py
Outdated
RequestCache.clear_all_namespaces() | ||
|
||
|
||
def prepare_for_new_work_cycle(): |
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.
@navinkarkera looking at this PR I see that the new utility function is added but not executed anywhere.
If so, that means that it is the signal handler that must explicitly call this prepare_for_new_work_cycle
function. Am I understanding the intent correctly?
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.
@felipemontoya Yes, that is correct. Have created a draft PR: openedx/event-bus-redis#56 in event bus redis to use this utility.
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.
This may be a good time to move https://openedx.atlassian.net/wiki/spaces/AC/pages/3662643205/How+to+add+a+new+concrete+implementation+of+the+event+bus to this repo and to update any incoming links to that doc to point to the newer version of the doc.
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.
@robrap Done, we can update the incoming links once this PR is merged.
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.
@navinkarkera: Were you still planning on updating the links?
f91067d
to
26e9aec
Compare
|
||
The consumer class then needs to implement ``consume_indefinitely`` loop, which will stay running and listen to events as they come in. | ||
|
||
If you are doing this within Django, one thing to be aware of is Django will not do any of the automatic connection cleanup that it usually does per request. This means that if your database restarts while the ``consume_indefinitely`` loop is running, Django may try to hold on to a defunct connection. To address this, we have included an `utility function <../../openedx_events/tooling.py#L323>`_ in openedx-events which needs to called before processing any signal. Checkout `consumer.py <https://github.com/openedx/event-bus-redis/blob/main/edx_event_bus_redis/internal/consumer.py>`_ in event bus redis implementation. We’re also resetting the RequestCache in the utility function, and there may be later, more comprehensive changes.. |
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.
TODO: update links in follow up PR
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.
Thanks for bringing in the doc.
@navinkarkera: This PR has been sitting for a couple of months. Do you intend to return to this? It would be great to get it landed. Thank you! |
@robrap Apologies, I got caught up with some other projects. I'll surely get this done within this week. |
26e9aec
to
bafcb7a
Compare
@robrap Thanks for your patience. Addressed your comments. Please have a look. |
Thanks @navinkarkera and @mphilbrick211. This is on my list, but I've got a long list and lots of days off, so this may take me a little time to get to. |
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.
Thanks @navinkarkera. It looks like your fixup
commit added requirements updates. Can we drop those changes from the PR, or do you need that for some reason? Other than that, this is ready to squash as-needed.
bafcb7a
to
4cf5488
Compare
@robrap Actually, we added |
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.
Sorry @navinkarkera. Would you mind just updating the date? Then I'll merge. Thanks.
CHANGELOG.rst
Outdated
@@ -14,6 +14,12 @@ Change Log | |||
Unreleased | |||
---------- | |||
|
|||
[9.3.0] - 2023-12-08 |
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.
[9.3.0] - 2023-12-08 | |
[9.3.0] - 2024-01-04 |
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.
@robrap Apologies for the delay. Updated the date.
4cf5488
to
b7f7df1
Compare
@navinkarkera: Apologies, but I totally spaced on merging this, and now it has conflicts. I'm sorry about that. If we get it up-to-date net week I will merge as soon as you tell me it is ready. Thank you! |
chore: bump version and update changelog chore: remove utility function from coverage docs: move how to add new implementation doc from atlassian docs: simplify consuming docs in how-to
b7f7df1
to
3fa34ad
Compare
@navinkarkera 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
Description: Adds utility function to reset application state which can be used by event bus implementation to reset request/db_connection before processing events.
ISSUE: openedx/event-bus-redis#49
Related:
Reviewers:
Merge checklist:
Post merge:
finished.
Author concerns: List any concerns about this PR - inelegant
solutions, hacks, quick-and-dirty implementations, concerns about
migrations, etc.