Skip to content

Commit

Permalink
Custom log level for TILED_DEBUG_LEAKED_THREADS
Browse files Browse the repository at this point in the history
  • Loading branch information
padraic-shafer committed Oct 25, 2023
1 parent 98b72cc commit ed3f561
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tiled/_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,18 @@ def tmpdir_module(request, tmpdir_factory):
return tmpdir_factory.mktemp(request.module.__name__)


# Use this with pytest --log-cli-level=INFO option.
# Use this with pytest --log-cli-level=25 option.
if os.getenv("TILED_DEBUG_LEAKED_THREADS"):
import logging
import threading
import time

def poll_enumerate():
logger = logging.getLogger(__name__)
msg_level = int(logging.INFO + logging.WARNING)//2
while True:
time.sleep(1)
logger.info("THREAD COUNT = %d", len(threading.enumerate()))
logger.log(msg_level, "THREAD COUNT = %d", len(threading.enumerate()))

thread = threading.Thread(target=poll_enumerate, daemon=True)
thread.start()
Expand Down

0 comments on commit ed3f561

Please sign in to comment.