Getting timeout logs every second when DEBUG=True
MarSoft opened this issue · comments
Приветствую.
При запущенном приложении с опцией DEBUG=True
почти каждую секунду получаю в логах по одной строчке такого вида: INFO:asyncio:poll 999.495 ms took 1000.397 ms: timeout
(см. ниже аттач).
Насколько я понял, логируется это где-то в недрах asyncio
, но вот чем оно вызвано и как побороть - неясно. С выключенным DEBUG
этих сообщений, само собой, не видно. Происходит даже с пустой аппой без каких-либо плагинов.
Посоветуйте, в каком направлении следует копать?
Пока нашёл соответствующий кусок кода из питоньих исходников: https://github.com/python/cpython/blob/3.5/Lib/asyncio/base_events.py#L1204
$ muffin main run
[2015-10-28 05:56:33 +0300] [2553] [INFO] Starting gunicorn 19.3.0
[2015-10-28 05:56:33 +0300] [2553] [INFO] Listening at: http://127.0.0.1:5000 (2553)
[2015-10-28 05:56:33 +0300] [2553] [INFO] Using worker: muffin.worker.GunicornWorker
[2015-10-28 05:56:33 +0300] [2565] [INFO] Booting worker with pid: 2565
INFO:asyncio:<Server sockets=[<socket.socket fd=8, family=AddressFamily.AF_INET, type=2049, proto=0, laddr=('127.0.0.1', 5000)>]> is serving
INFO:asyncio:poll 999.717 ms took 1003.139 ms: timeout
INFO:asyncio:poll 999.137 ms took 1000.672 ms: timeout
INFO:asyncio:poll 999.259 ms took 1000.242 ms: timeout
INFO:asyncio:poll 999.156 ms took 1001.158 ms: timeout
INFO:asyncio:poll 999.094 ms took 1001.137 ms: timeout
INFO:asyncio:poll 999.574 ms took 1001.132 ms: timeout
INFO:asyncio:poll 999.408 ms took 1001.087 ms: timeout
INFO:asyncio:poll 999.502 ms took 1001.118 ms: timeout
INFO:asyncio:poll 999.502 ms took 1000.858 ms: timeout
INFO:asyncio:poll 998.919 ms took 1000.138 ms: timeout
INFO:asyncio:poll 999.406 ms took 1001.078 ms: timeout
INFO:asyncio:poll 999.495 ms took 1000.397 ms: timeout
Система (в virtualenv):
Python 3.5.0
aiohttp==0.17.4
Babel==2.1.1
cached-property==1.2.0
chardet==2.3.0
decorator==4.0.4
gunicorn==19.3.0
ipython==4.0.0
ipython-genutils==0.1.0
Jinja2==2.7.3
MarkupSafe==0.23
muffin==0.2.1
muffin-admin==0.1.3
muffin-babel==0.0.6
muffin-debugtoolbar==0.1.2
muffin-jinja2==0.1.0
muffin-peewee==0.4.0
muffin-session==0.0.8
path.py==8.1.2
peewee==2.6.4
pexpect==4.0.1
pickleshare==0.5
ptyprocess==0.5
PyMySQL==0.6.7
pytz==2015.7
simplegeneric==0.8.1
speaklater==1.3
traitlets==4.0.0
ujson==1.33
wheel==0.24.0
WTForms==2.0.2
PS. Прошу прощения за простыню, аттач гитхаб не позволяет сделать.
Сейчас уже сходу и не скажу чем вызвана проблема, исследую позже как будет время. Спасибо за фидбек.
(for anyone who worries about this but didn't get the answer)
GunicornWorker here is setting asyncio's loop to debug mode according to DEBUG variable in app config.
These messages mean only that worker receives no requests.
Here is a workaround I use for this issue:
in config_dev.py
file, after DEBUG = True
I added the following code:
DEBUG = True
# avoid frustrating INFO messages about timeout caused by sleep(1)
import logging
class SkipTimeouts(logging.Filter):
def filter(self, rec):
if(rec.levelno == logging.INFO and
rec.msg.startswith('poll') and
rec.msg.endswith(': timeout') and
990 < rec.args[0] < 1000 and
1000 < rec.args[1] < 1010):
return False # hide this record
return True
logging.getLogger('asyncio').addFilter(SkipTimeouts())
I believe is not a muffin bug and the issue can be closed
@drgarcia1986 agree