Start scan from current point after restart, soft-ban detection, and a shutdown function on banned#249
Open
gunawanputra wants to merge 9 commits intomodrzew:masterfrom
Open
Start scan from current point after restart, soft-ban detection, and a shutdown function on banned#249gunawanputra wants to merge 9 commits intomodrzew:masterfrom
gunawanputra wants to merge 9 commits intomodrzew:masterfrom
Conversation
Changes to be committed: modified: requirements.txt modified: worker.py Untracked files: src/
modified: worker.py Untracked files: src/
…n response have status_code 3
modified: worker.py change api to commit 8c1c176, add pgoapi_exceptions.NotLoggedInException to cycle loop.
|
This really is too many Features in a single PR. Especially since ban detection is already in master. |
Author
|
Ban detection in master only detect permanent ban (status_code=3), and will keep restart worker when BannedAccount exception raised. |
|
Workers are restarting because we experienced some false positive with status_code 3. You can look at the discussion here : #244 |
…mber of forts and pokemon seen
Author
|
Restarting because of some false positive with status_code 3, but then workers with permanent banned account will just keep restarting. On the newest commit, I even add permanent ban boolean status that set to true when response have status_code 3. Then if it's just false positive like what you said, will set to false after point is processed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Soft-ban could be detected when get_map_objects response only have current_timestamp and cell_id, which will make a point processed without any pokemon and fort found. By counting how many times forts result is empty, we could find out when a worker is banned. Right now worker thread will be terminated (I use word shutdown) when it get banned.
MalformedResponse exception currently is not in use. I put a try-except block when assign value of response_dict to map_objects and handle the TypeError exception.
I did this because response_dict have a NoneType when "server is busy or offline" and in this situation I think it's better if worker simply move to the next point and try to send another request rather than restart itself. There is also "sequence index must be integer, not 'str'" error, happen when worker considered not logged in by pgoapi. Worker need an immediate restart and relogin on this error.
For now I just put banned_count in the try-except block to shutdown the worker if it keep getting TypeError. It's better to create a counter and count how many times this TypeError happen, especially sequence index error, and raise MalformedResponse to restart worker when it reach the limit.
--edit--
On pgoapi commit 8c1c176, api will raise NotLoggedInException instead of return NotLoggedInException. This will make "TypeError : sequence index must be integer, not 'str'" exception never happen again. NotLoggedInException exception handling added in try-except block in cycle while loop, will restart worker when this exception raised.
banned_count removed from TypeError exception handling.