modrzew / pokeminer

Pokemon location scraper
MIT License
220 stars 62 forks source link

So many Threads #248

Closed SapitoSucio closed 7 years ago

SapitoSucio commented 7 years ago

Threads won't stop growing with the newest commits, in my pokeminer it starts with 80 threads, right now it has 423, consuming 830MB of RAM

YonderGod commented 7 years ago

Try removing line 101 in worker.py service = config.ACCOUNTS[self.worker_no][2]

I think this fixed it for me.

SapitoSucio commented 7 years ago

It keeps growing @YonderGod

YonderGod commented 7 years ago

hmm, I guess it was just a coincidence, it took a lot longer for them the number to start going up.

getting lots of these errors, not sure if related

[2016-08-17 17:44:18,175][worker-108][   ERROR][L 151] A wild exception appeared!
Traceback (most recent call last):
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\sqlalchemy\pool.py", line 1044, in _do_get
    return self._pool.get(wait, self._timeout)
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\sqlalchemy\util\queue.py", line 156, in get
    raise Empty
sqlalchemy.util.queue.Empty

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "worker.py", line 142, in run
    self.main()
  File "worker.py", line 226, in main
    db.add_sighting(session, raw_pokemon)
  File "C:\Users\yonde\Desktop\pokeminer-master\db.py", line 188, in add_sighting
    .filter(Sighting.lon == pokemon['lon']) \
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\sqlalchemy\orm\query.py", line 2659, in first
    ret = list(self[0:1])
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\sqlalchemy\orm\query.py", line 2457, in __getitem__
    return list(res)
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\sqlalchemy\orm\query.py", line 2761, in __iter__
    return self._execute_and_instances(context)
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\sqlalchemy\orm\query.py", line 2774, in _execute_and_instances
    close_with_result=True)
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\sqlalchemy\orm\query.py", line 2765, in _connection_from_session
    **kw)
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\sqlalchemy\orm\session.py", line 893, in connection
    execution_options=execution_options)
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\sqlalchemy\orm\session.py", line 898, in _connection_for_bind
    engine, execution_options)
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\sqlalchemy\orm\session.py", line 334, in _connection_for_bind
    conn = bind.contextual_connect()
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\sqlalchemy\engine\base.py", line 2039, in contextual_connect
    self._wrap_pool_connect(self.pool.connect, None),
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\sqlalchemy\engine\base.py", line 2074, in _wrap_pool_connect
    return fn()
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\sqlalchemy\pool.py", line 376, in connect
    return _ConnectionFairy._checkout(self)
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\sqlalchemy\pool.py", line 713, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\sqlalchemy\pool.py", line 480, in checkout
    rec = pool._do_get()
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\sqlalchemy\pool.py", line 1053, in _do_get
    (self.size(), self.overflow(), self._timeout))
sqlalchemy.exc.TimeoutError: QueuePool limit of size 5 overflow 10 reached, connection timed out, timeout 30
gunawanputra commented 7 years ago

add return on exception

        except MalformedResponse:
            logger.warning('Malformed response received!')
            self.restart()
            return
   except BannedAccount:
            self.error_code = 'BANNED?'
            self.restart(30, 90)
            return

when thread restart() without return, main thread will create a new thread while thread that call restart function remain active.

theresthatguy commented 7 years ago

same here as YonderGod

modrzew commented 7 years ago

Hopefully fixed in f61ba4079d30647bd0f7aa00c590def6d563573c.