Debug gevent hangs
This commit is contained in:
parent
78a7542b4d
commit
ba851a684c
2 changed files with 17 additions and 0 deletions
|
@ -119,6 +119,7 @@ class Config(object):
|
||||||
self.parser.add_argument('--verbose', help='More detailed logging', action='store_true')
|
self.parser.add_argument('--verbose', help='More detailed logging', action='store_true')
|
||||||
self.parser.add_argument('--debug', help='Debug mode', action='store_true')
|
self.parser.add_argument('--debug', help='Debug mode', action='store_true')
|
||||||
self.parser.add_argument('--debug_socket', help='Debug socket connections', action='store_true')
|
self.parser.add_argument('--debug_socket', help='Debug socket connections', action='store_true')
|
||||||
|
self.parser.add_argument('--debug_gevent', help='Debug gevent functions', action='store_true')
|
||||||
|
|
||||||
self.parser.add_argument('--batch', help="Batch mode (No interactive input for commands)", action='store_true')
|
self.parser.add_argument('--batch', help="Batch mode (No interactive input for commands)", action='store_true')
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import traceback
|
import traceback
|
||||||
|
from Config import config
|
||||||
|
|
||||||
|
|
||||||
# Non fatal exception
|
# Non fatal exception
|
||||||
|
@ -28,6 +29,21 @@ def formatException(err=None, format="text"):
|
||||||
else:
|
else:
|
||||||
return "%s: %s in %s" % (exc_type.__name__, err, " > ".join(tb))
|
return "%s: %s in %s" % (exc_type.__name__, err, " > ".join(tb))
|
||||||
|
|
||||||
|
# Test if gevent eventloop blocks
|
||||||
|
if config.debug_gevent:
|
||||||
|
import logging
|
||||||
|
import gevent
|
||||||
|
import time
|
||||||
|
def testBlock():
|
||||||
|
logging.debug("Gevent block checker started")
|
||||||
|
last_time = time.time()
|
||||||
|
while 1:
|
||||||
|
time.sleep(1)
|
||||||
|
if time.time()-last_time > 1.1:
|
||||||
|
logging.debug("Gevent block detected: %s" % (time.time()-last_time-1))
|
||||||
|
last_time = time.time()
|
||||||
|
gevent.spawn(testBlock)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue