IOError: [Errno 24] Too many open files
Expected Behavior
Not crash
Actual Behavior
Crash
Steps to Reproduce
Run bot and have the map open for a while
Other Information
OS: Windows 10 Browser: Chrome v51.0.2704.103 Python 2.7.12
Full stack trace
[16:24:14] Moving towards fort ..., 0.17km left
Traceback (most recent call last):
File "pokecli.py", line 408, in
Sounds like files are not properly getting closed by the bot. Can you include the git revision that made this happen?
Ok, i also got this a few times :smile:
OS Windows 7 x64 two different PC
commit c5483349e02fc0b1c8c8ed31411ae8ca71ec4177
[15:29:51] Something rustles nearby!
[15:29:52] A Wild Gastly appeared! [CP 98] [Potential 0.67]
[15:29:52] IV [Stamina/Attack/Defense] = [5/13/12]
Traceback (most recent call last):
File "pokecli.py", line 408, in <module>
File "pokecli.py", line 68, in main
File "E:\pokego\pokemongo_bot\__init__.py", line 92, in tick
File "E:\pokego\pokemongo_bot\cell_workers\catch_visible_pokemon_worker.py", line 37, in work
File "E:\pokego\pokemongo_bot\cell_workers\catch_visible_pokemon_worker.py", line 76, in catch_pokemon
File "E:\pokego\pokemongo_bot\cell_workers\pokemon_catch_worker.py", line 80, in work
File "E:\pokego\pokemongo_bot\__init__.py", line 377, in current_inventory
IOError: [Errno 24] Too many open files: u'web/inventory-username.json'
commit be9e7bb79de33a7d177014184c510b2c60513be8
[18:36:53] -- Recycled 1x Potion (keeps only 10 maximum)
[18:36:53] Moving towards fort **********************.12, 0.11km left
[18:36:59] Session stale, re-logging in
[18:36:59] Attempting login to Pokemon Go.
[18:37:01] Login to Pokemon Go successful.
[18:37:03] Moving towards fort ***************************.12, 0.07km left
Traceback (most recent call last):
File "pokecli.py", line 408, in <module>
File "pokecli.py", line 68, in main
File "J:\pokemongo\pokemongo_bot\__init__.py", line 94, in tick
File "J:\pokemongo\pokemongo_bot\cell_workers\move_to_fort_worker.py", line 53, in work
File "J:\pokemongo\pokemongo_bot\step_walker.py", line 59, in step
File "J:\pokemongo\pokemongo_bot\__init__.py", line 490, in heartbeat
File "J:\pokemongo\pokemongo_bot\__init__.py", line 158, in update_web_location
IOError: [Errno 24] Too many open files: u'data/cells-username.json'
[19:14:29] - 1x Pokeball (Total: 28)
[19:14:29] PokeStop on cooldown. Time left: 4 minutes, 59 seconds
Traceback (most recent call last):
File "pokecli.py", line 408, in <module>
File "pokecli.py", line 68, in main
File "J:\pokemongo\pokemongo_bot\__init__.py", line 97, in tick
File "J:\pokemongo\pokemongo_bot\spiral_navigator.py", line 71, in take_step
File "J:\pokemongo\pokemongo_bot\step_walker.py", line 59, in step
File "J:\pokemongo\pokemongo_bot\__init__.py", line 490, in heartbeat
File "J:\pokemongo\pokemongo_bot\__init__.py", line 158, in update_web_location
IOError: [Errno 24] Too many open files: u'data/cells-username.json'
on the last time i ran "Handle", to see how many handles open by a python process this is after ~30min of running bot
C:\>handle -p python.exe -s
Nthandle v4.1 - Handle viewer
Copyright (C) 1997-2016 Mark Russinovich
Sysinternals - www.sysinternals.com
Handle type summary:
ALPC Port : 2
Desktop : 1
Directory : 2
EtwRegistration : 14
Event : 79
File : 2067
IoCompletion : 3
Key : 7
KeyedEvent : 1
Mutant : 2
Process : 5
Semaphore : 3
Thread : 5
Timer : 3
TpWorkerFactory : 16
WindowStation : 2
Total handles: 2212
and after that i got a crash, because of operationg system limit ~2048..
and again:
[19:59:47] PokeStop on cooldown. Time left: 4 minutes, 59 seconds
[19:59:57] -- Recycled 1x Greatball (keeps only 30 maximum)
[19:59:57] Moving towards fort **************************.12, 0.09km left
Traceback (most recent call last):
File "pokecli.py", line 408, in <module>
File "pokecli.py", line 68, in main
File "J:\pokemongo\pokemongo_bot\__init__.py", line 94, in tick
File "J:\pokemongo\pokemongo_bot\cell_workers\move_to_fort_worker.py", line 53, in work
File "J:\pokemongo\pokemongo_bot\step_walker.py", line 59, in step
File "J:\pokemongo\pokemongo_bot\__init__.py", line 490, in heartbeat
File "J:\pokemongo\pokemongo_bot\__init__.py", line 158, in update_web_location
IOError: [Errno 24] Too many open files: u'data/cells-username.json'
before crash:
C:\>handle -p python.exe -s
Nthandle v4.1 - Handle viewer
Copyright (C) 1997-2016 Mark Russinovich
Sysinternals - www.sysinternals.com
Handle type summary:
ALPC Port : 2
Desktop : 1
Directory : 2
EtwRegistration : 14
Event : 79
File : 2061
IoCompletion : 3
Key : 7
KeyedEvent : 1
Mutant : 2
Process : 1
Semaphore : 3
Thread : 5
Timer : 3
TpWorkerFactory : 16
WindowStation : 2
Total handles: 2202
handles increasing every 10 seconds by ~10.
I am on the dev branch commit c548334
I figured it out, it's within the pgoapi "subprocess.Popen"
Nice, If you aren't running the webpage it takes longer, but eventually presents as a connection error from the api wrapper when the handles max out.
Server seems to be busy or offline - try again - 1/5 Server seems to be busy or offline - try again - 2/5 Server seems to be busy or offline - try again - 3/5 Server seems to be busy or offline - try again - 4/5 Server seems to be busy or offline - try again - 5/5 ... pgoapi.exceptions.ServerBusyOrOfflineException
Looks like this was merged, should we update requirements.txt? 441925eb7b346ed60ebf8eb537b0dad682a2fff0
Edit: Nope, looks like the pgoapi doesn't play nice at that commit.
pgoai fixed the Popen issue here: https://github.com/tejado/pgoapi/commit/e6db98b9a931731a9f449365a31dc1a9b794f5a0
But there are a lot of changes at this commit's point that breaks backwards compatibility. Anyone willing to work on migrating the bot's code to be able to use this commit from pgoapi?
We have newer pgoapi now with these fixes.