multithreading - python logging shows no sys.stdout when from different thread -


i have strange problem logging in multithreaded python application. whenever debug application, see logging output in stdout, such

2016-11-05 21:51:36,851 (connectionpool.py:735 mainthread) info -     requests.packages.urllib3.connectionpool: "starting new https connection (1): api.telegram.org" 2016-11-05 21:51:41,920 (converter.py:16 workerthread1) debug - converter: "resizing file test/test_input/" 2016-11-05 21:51:50,199 (bot.py:221 workerthread1) error - __main__: "moviepy error: failed read duration of file test/test_input/.  

however, when run code without debug, logs workingthread1 disappear, leaving mainthread ones. code unchanged , error remains. guess has multithreading. workerthread1 started pytelegrambotapi framework. have logs output sys.stdout:

formatter = logging.formatter(     '%(asctime)s (%(filename)s:%(lineno)d %(threadname)s) %(levelname)s - %(name)s: "%(message)s"') stream_handler = logging.streamhandler(sys.stdout) stream_handler.setformatter(formatter) root = logging.getlogger() root.setlevel(logging.notset) root.addhandler(stream_handler) 

any ideas?

update: has 100% multithreading, because when tell framework use 1 thread, logging messages appear. pytelegrambotapi uses workerthread , threadpool implement concurrency exemplified here

you have show more code. in code have shown, stream_handler created, handler used in addhandler.

my guess logging level improperly set causing logs workingthread1 not logged.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -