<s> from __future__ import absolute_import <EOL> import logging <EOL> import pythoncom <EOL> import threading <EOL> log = logging . getLogger ( __name__ ) <EOL> class Com ( object ) : <EOL> def __init__ ( self ) : <EOL> self . need_com_init = not self . _is_main_thread ( ) <EOL> def _is_main_thread ( self ) : <EOL> return threading . current_thread ( ) . name == '<STR_LIT>' <EOL> def __enter__ ( self ) : <EOL> if self . need_com_init : <EOL> log . debug ( '<STR_LIT>' ) <EOL> pythoncom . CoInitialize ( ) <EOL> def __exit__ ( self , exc_type , exc_value , traceback ) : <EOL> if self . need_com_init : <EOL> log . debug ( '<STR_LIT>' ) <EOL> pythoncom . CoUninitialize ( ) </s>
