-
-
Notifications
You must be signed in to change notification settings - Fork 403
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
reload: fix to handle removed callables + cleanly remove intervals + missing priority
error
#1399
reload: fix to handle removed callables + cleanly remove intervals + missing priority
error
#1399
Conversation
Well darn. Can't figure out checkstyle errors for failed travis-ci |
@HumorBaby I figured out what's going on. My local versions are up-to-date now, too. I'll review the changelogs for |
@dgw sounds good to me. No rush though. Thanks for looking into that. My gut says new PR since I'm building off a new branch of yours. But I could see how its possible to bring those changes from your branch into this history... |
@HumorBaby You can continue committing on this branch; don't worry about the history for now. I'll walk you through the rebase process to clean it later, if/when the PR becomes ready to merge. It's much easier to have the evolution of a change all in one place, than to chase it between several closed PRs. 😸 For now, just keep doing your thing and ignore the CI errors from style checks. Sometimes the search module tests throw random errors, too, and you can also ignore those if they happen. The only errors you should worry about on a PR, in most cases, are errors in files you touched. Most other errors can be safely ignored, except in specific circumstances. |
@dgw will do. Thanks again |
Note for myself: under b2d805d (reload fix with recursion + no dupes), reloading a module that failed to load during startup will throw a
|
If a module failed to load, it probably shouldn't be reloadable. Reloading should just fail in that case with a "module not loaded, try the load command" error. |
@HumorBaby With #1314 merged, this will need a rebase. The history is messy enough that it was going to need one anyway… 😁 I'm sure you were already planning to! But I found another bit/piece in commit 03215f6 that you might or might not find useful as you continue working on this. It's been a while since I touched it and I don't remember what the test results were like. It probably didn't work very well and/or broke something, since I never put it in #1314, but it's still an idea… |
@HumorBaby I'm hoping that the last remaining edge cases can be fixed in Sopel 7. For example, #1314 does not (IIRC) handle removed methods well, only added and updated ones. :) |
@dgw I didn't get around to testing removed methods either. I can take a look when I'm stepping through the reload process. Reptarsaurus in #sopel mentioned that |
@HumorBaby I'm really not sure what's up with Lines 245 to 248 in 73fd522
…and cleared when any callable (#831) is unregistered: Lines 219 to 222 in 73fd522
…but clearly (ha!) something is wrong with this logic—beyond the problem of deleting all jobs from the scheduler when we only want to remove a specific one. I don't think that a hypothetical |
4e77958
to
a3e143c
Compare
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.
Comments are for me to remember why I had made certain changes before the rebase. Also, I can design my tests around these changes I thought were important at the time of beginning this fix.
a3e143c
to
f1956f8
Compare
Force push was to get the latest tests as I |
Oh dear... turns out removed functions from a module are not only not-removed, but also get duplicated repsonses 😢 just fyi... looking into this first as a means to solve the actual problem at hand: remove removed callables |
Oops! |
@HumorBaby I remember you were playing around with this a week or two ago. Did that go anywhere? |
@dgw, I haven't looked at it too much since then because tracing through
However, I don't think that it is impossible. It will just require a little bit of 🔨 to make it fit. My goal is still to minimize changes to the current implementation to avoid introducing new issues before the whole process is replaced by something likes #1490/Py3. It feels within reach In the mean time, the following changes were made (or will be made immediately following this):
|
Previously, all callables using `@interval` were removed when a single module was reloaded. Now, the `JobScheduler` can remove a single callable from the jobs queue, and `bot.unregister` has been updated to use `JobScheduler.remove_callable_job` instead of `JobScheduler.clear_jobs`.
f1956f8
to
6d3cabb
Compare
RE: removing While #1053 already proposed a solution to this issue: Lines 83 to 88 in 6d66ab0
That approach of iterating the job queue didn't sit quite right with me. Given the nature of Lines 93 to 104 in 6d3cabb
I will gladly pick this out of #1053 (since that work was done first) if anyone believes it to be a safe solution to this issue 😄 Note: while this solves the problem of removing only the reloaded |
@dgw, how do you feel about changing this PR to deal solely with
This would let the issue of |
@HumorBaby It's kinda whatever. Fix what you can, when you can, you know? 😁 And retitle it to match when you update, of course. Is there a currently open issue that would be good to use for tracking all the reload bugs/quirks, or would you rather just open a fresh one and populate it with a checklist of the current state? Maybe with references to the other issues/PRs open that relate to it? I'm kind of swamped both IRL and on GitHub at present, but it would be amazing if you have time to put together something like that! |
@dgw desribed an issue where calling Preliminary debug-prints indicated that callables did in fact "have @HumorBaby suggested that non-callables (not called by the bot) were triggering this issue, but alas there was an "AttributeError in bot.unregister() on object issue_info". The best current hypothesis is: "so it's still possibly a weird thing with callables from not-__init__.py but a really obscure one", potentially stemming from the previous recursion fix for |
priority
error
If a callable was imported like from .module import *, the recursion used in `reload.py` would catch the callable twice. The first time around, when the object name has the format `module.submodule...`, the callable obj has the rules as uncompiled regexp strings and no associated priority, and so causes issues in the `bot.unregister` method. The second time, the object name is just the object name and now rules have been compiled (with associated priorities). This is **only** observed with the `@rule`-decorated callables, and not with `@command`-decorated ones. While the object that with the `module.submodule...` in the name does actually exist, it is not used anywhere and just hangs around. It's like a human wisdom tooth... Since it has no effect on bot function, as it is never registered and the bot is unaware of its existence, we can just ignore it by checking if the callable object name contains a `.` Upon finding a `.`, we just skip `unregister`'ing it. Also, while dealing with this, I added a check to ensure that compiled rules are added to a callable's rules list only once. While not directly contributing to the issue, it was tangentially related, and worth refactoring.
re: the It turns out that it was directly related to the original issue for which I opened the PR (which has now become this box of smashed crabs). One quick and dirty fix is the just ignore objects with |
I can almost guarantee that the new interface will get merged before this (or anything else related to the issues with Hopefully that won't be too much of an issue for you, what with having to take each of your fixes and figure out if it's still needed under the new system, then port the patch if so. 😁 This week is a busy one for me IRL (tech week for an operetta) but I still hope to find the time for reviewing #1479 and #1490 by the end of March. I hope they can be merged without too much fuss, so we can move from the overall system to the smaller bugs like what this PR wants to fix. |
Sounds good to me 😄 I'll just drop keep dropping commits in here to keep track of things then |
Is this still needed after #1479, @HumorBaby? I'm not sure if you and @Exirel have combined efforts. |
🎉 |
EDIT: rebased; some comments no longer apply.
Attempt #2 (see #1398)
This commit attempts to address #1056 . @dgw did most of the work here.
, as I am working off his fork. @dgw has two branches for #1056 (one for reloading with recursion, and one for preventing duplicates). Since they both address reloading issues, I combined the changes from both branches into one. On top of that,I don't think the fix submitted in #1314 works completely for all cases. For example, when a module is defined with callables from a submodule imported into the init, additional issues arise.For example,
my_sopel_module/some_submodule.py
my_sopel_module/__init__.py
leads to issues in the recursion, where the same module is found as
my_sopel_module.some_submodule
, andsome_submodule
. I added a condition to check for.
in the module name, and ignore if that is the case. This should still work under all previously passing tests.