-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
RecycleItems task not running frequently enough #4417
Comments
Just had a look through the code (recycle_items.py) and it appears as though the RecycleItems task will only run if space in the bag is less than min_empty_space:
At least I understand why this happens, but it's causing my bag to fill up with basic pokeballs to the detriment of everything else. At this stage, I've just added a random chance of forcing the recycle every 20 bot cycles (give or take), but that's unbelievably inelegant. Can this be set to run on a timer regardless of whether min_empty_space has been reached? |
I've added a feature to my code which allows scheduling of a "forced" recycle at a random interval between a given min and mix duration (set in config.json), regardless of whether min_empty_space is reached. Tested and working well. There are three changed files, recycle_items.py, colored_logging_handler.py and init.py, plus additions to config examples. Can someone please advise what I should do to submit my code for review/inclusion in the official dev branch? (sorry, this is the first time I've worked on a community git project). |
👍 |
I believe Gregwar is correct. As it stands, the only time web inventory is updated is when RecycleItems is triggered, which is currently only when your bag is almost full. Even then, it only updates after the categories are processed, but not after going through the individual items in the filters, which means it may still be incorrect if you have individual "keep" settings for various items. Looking further into this, I have a couple of issues with the way the item recycling code currently works as follows:
I have a working copy of the code that addresses all these issues. Still need advice on how to submit for review. |
Re item 3 above, it looks like #3948 has something to do with this. Added "inventory.refresh_inventory()" to the "tick" function in init.py (line 535) forces an inventory refresh every bot tick. |
Yes @mjmadsen, that is occurring, however the code has recently (a week or so ago) been changed so that recycling will only occur when space remaining reaches a given threshold. In my case, this is defined as "15" but the default is 6. The bot should ideally recycle whenever any of the items in the filter list are above the count specified. Additionally, the bot's inventory is only updated when recycling occurs, leading to major discrepancies between the bot's internal inventory and the web interface. As mentioned, I have made modifications to my code to address this. Would appreciate advice on how to get this code reviewed as I don't have permission to create a branch, create a pull request etc. |
Take a look at the doc, it explains how to recycle every tick. |
I don't know exactly what you're referring to, but the doc(s) included with the distribution does not explain how to recycle every tick. Even if some doc somewhere explains this, the code does not currently support running every tick at all. The "work" function of recycle_item.py calls the "should_run" function, and the only criteria for running is whether or not min_empty_space is exceeded.
I suppose you could force it to run every tick by setting min_empty_space to something like 250, but that would be a bit silly. I'm also absolutely sure this task doesn't write to a file. It does, however, call inventory.refresh, which writes its output to a file, specifically web/inventory-%username%.json. Nothing else in the code currently calls inventory.refresh, hence the huge delays in updating the web interface. Still looking for advice regarding submitting code for review, thanks. Also very happy to be proven wrong :) |
@Gobberwart You can "fork" this by clicking it in the top right corner. Then you can work in your own space with the current commit. When you finish making changes to the dev branch you can go to "Pull Request" to submit your changes to our dev branch. |
Thank you for pointing out this inventory refresh. It shouldn’t be there anymore, looks like I forgot one when resolving conflicts. We’re moving away from writing in files. With our new map we won’t need it anymore. That being said, it’s not ready yet. I guess there is quite a lot of people who want this. Refreshing the inventory at every tick could be a temporary solution. About the documentation you can find it on our homepage. You should change your config if you want RecycleItems to run more frequently. Increase the min_empty_space or decrease amounts to keep in inventory. Or both. That’s why we have a customizable config file after all. |
OK, I've submitted a pull request #4513. Would appreciate any feedback. |
EDIT: I have investigated this, and have made modifications to the code to address the issue. Currently seeking assistance with submitting changes for review if anyone can assist?
Expected Behavior
Bot should recycle items every few minutes, keeping no more than the specified number of each item type.
Actual Behavior
ItemRecycler appears very rarely in the log so bag fills up with pokeballs unnecessarily.
Config.json has the following config for RecycleItems:
Output shows:
Next update of items shows:
This appears to have worked, but it's been over an hour and the ItemRecycler task has not run since, so now I have:
Update: The ItemRecycler task just happened again, but it was more than an hour between runs.
Your FULL config.json
Output when issue occurred
N/A (See above)
Steps to Reproduce
Run the bot and wait.
Other Information
OS: Windows 10
Branch: dev
Git Commit: cf4b458
Python Version: 2.7
The text was updated successfully, but these errors were encountered: