Closed fojetin closed 5 years ago
The best solution is to properly disconnect
the client, though. with client
will handle it for you.
logging_conf.txt logging_error.txt
Below is my logger generating script
def set_logger(conf_path, log_handler, log_name):
print("Conf Path", conf_path)
"""Setup logging configuration"""
if os.path.exists(conf_path):
with open(conf_path, 'rt') as f:
config = json.load(f)
log_path = os.path.join(constants.LOG_DIR, log_name)
# logging file name with timestamp
config["handlers"]["file_handler"]["filename"] = log_path
logging.config.dictConfig(config)
logger = logging.getLogger(log_handler)
return logger
else:
print("Logger Configuration file not found..")
sys.exit(1)
if __name__ == "__main__":
now = datetime.datetime.now()
timestamp = now.strftime("%Y%m%d")
log_name = "cvm_adapter_{}.log".format(timestamp)
logger = setup("configs\logging_conf.json", __file__, "test_log.log")
I've 6 modules, from each module I'm calling the above function to return the logger. Everytime the module completes execution I'm getting the same error as
--- Logging error ---
Traceback (most recent call last):
File "/usr/lib64/python3.6/logging/handlers.py", line 71, in emit
if self.shouldRollover(record):
File "/usr/lib64/python3.6/logging/handlers.py", line 185, in shouldRollover
self.stream = self._open()
File "/usr/lib64/python3.6/logging/__init__.py", line 1061, in _open
return open(self.baseFilename, self.mode, encoding=self.encoding)
NameError: name 'open' is not defined
Call stack:
File "/usr/local/lib/python3.6/site-packages/smpplib/client.py", line 97, in __del__
logger.warning('%s was not closed' % self)
Message: '<smpplib.client.Client object at 0x7fe4ed622550> was not closed'
Arguments: ()
I've tried to close the client object using with
but still got the same error.
Any help is really appreciated (client project)
@vjaychander nowhere in your traceback it says "telethon", so please keep this repository's issue tracker for Telethon-related issues only.
I think bug related to this question: https://stackoverflow.com/questions/23422188/why-am-i-getting-nameerror-global-name-open-is-not-defined-in-del