Good tip. Thanks. Seems like something that should end up in the public version.
___________________________ *www.TenOutOfTen.org* <https://www.TenOutOfTen.org> rogers...@gmail.com (+95) 09 250018669 (Myanmar) On Tue, 10 Nov 2020 at 23:09, Davidiam <david.rosa...@gmail.com> wrote: > We found that by modifying the gluon\admin.py app_uninstall function, we > could search for the open log file handles and close them before the actual > delete of the files is performed. > > import logging > import logging.handlers > > for nm, lgr in logging.root.manager.loggerDict.items(): > if str(nm) == str(app): > for h in lgr.handlers: > h.close() > On Tuesday, October 27, 2020 at 2:09:51 PM UTC+1 Davidiam wrote: > >> It looks like it uses one handler although the logger rotates the actual >> log files. I think that I would need to shut down the logger before or at >> the beginning of the uninstall step, but as the "uninstall application" is >> run from the admin app, it would be a bit tricky to implement the shutdown >> for a specific application in the admin application code. If there was an >> app.shutdown() method maybe.... >> >> For the moment I am first shutting down the application pool in IIS and >> then deleting the app but I would prefer a coded solution. We son't delete >> applications aften, so the work-around is acceptable for the moment. >> >> On Tuesday, October 27, 2020 at 4:23:09 AM UTC+1 roge...@gmail.com wrote: >> >>> Ah, i see. Can you temporarily shutdown() the logger and then restart it >>> when the uninstall is complete? Or does it need to stay running also? I >>> think it is possible to close a specific handler as well - but i dont know >>> how the logging works in web2py - maybe there is a single handler for all >>> the apps (if you can't tell, i have never used it before :) >>> >>> >>> ___________________________ >>> *www.TenOutOfTen.org* <https://www.TenOutOfTen.org> >>> roge...@gmail.com >>> (+95) 09 250018669 <+95%209%20250%20018%20669> (Myanmar) >>> >>> >>> On Mon, 26 Oct 2020 at 23:37, Davidiam <david....@gmail.com> wrote: >>> >>>> Thank you for your reply, >>>> Deleting the application folder gives the same error. >>>> The problem is that the logger holds the log file locked. If I restart >>>> the webserver I can delete the file, but our developers can't restart web >>>> services. >>>> It is not a big problem but I would like to find a solution (if one >>>> exists).. >>>> >>>> On Monday, October 26, 2020 at 4:56:30 AM UTC+1 roge...@gmail.com >>>> wrote: >>>> >>>>> Hi David >>>>> >>>>> I am not sure that i have ever used the Uninstall option. I just >>>>> delete the application folder and the application disappears. I am not >>>>> sure >>>>> if that leaves any residual information in files somewhere. But i have not >>>>> noticed a problem. >>>>> >>>>> Does that work for you? >>>>> Andrew >>>>> >>>>> ___________________________ >>>>> *www.TenOutOfTen.org* <https://www.TenOutOfTen.org> >>>>> roge...@gmail.com >>>>> (+95) 09 250018669 <+95%209%20250%20018%20669> (Myanmar) >>>>> >>>>> >>>>> >>>>> On Fri, 23 Oct 2020 at 17:07, Davidiam <david....@gmail.com> wrote: >>>>> >>>>>> When using logging in web2py on Windows, we are unable to delete >>>>>> applications unless we first stop the server. >>>>>> >>>>>> The reason is that the app.log is considered "in use". >>>>>> >>>>>> As the uninstall happens from the admin app, I am not quite sure how >>>>>> best to stop the logger in the application that is being uninstalled when >>>>>> the "Uninstall" option is selected from admin. >>>>>> >>>>>> Anyone have any ideas on how to unistall an app that uses logging. >>>>>> Apparently this is only an issue on Windows because the os.unlink works >>>>>> on >>>>>> "in use" files on linux systems. >>>>>> >>>>>> Note : We have defined the location of the log files within the >>>>>> application directory structure so that the developers have access to the >>>>>> files. >>>>>> >>>>>> This is the logging code used : >>>>>> def get_configured_logger(name): >>>>>> Test = False >>>>>> logger = logging.getLogger(name) >>>>>> if (len(logger.handlers) == 0): >>>>>> # This logger has no handlers, so we can assume it hasn't yet >>>>>> been configured >>>>>> # (Configure logger) >>>>>> >>>>>> # Create default handler >>>>>> if request.env.web2py_runtime_gae: >>>>>> # Create GAEHandler >>>>>> handler = GAEHandler() >>>>>> else: >>>>>> # Create RotatingFileHandler >>>>>> import os >>>>>> formatter="%(asctime)s %(levelname)s %(process)s %(thread)s >>>>>> %(funcName)s():% (lineno)d %(message)s" >>>>>> handler = >>>>>> logging.handlers.RotatingFileHandler(os.path.join(request.folder, >>>>>> 'private/app.log'), maxBytes=1000000,backupCount=2) >>>>>> handler.setFormatter(logging.Formatter(formatter)) >>>>>> >>>>>> handler.setLevel(logging.DEBUG) >>>>>> >>>>>> logger.addHandler(handler) >>>>>> logger.setLevel(logging.DEBUG) >>>>>> >>>>>> # Test entry: >>>>>> >>>>>> if Test == True: >>>>>> logger.debug(name + ' logger created') >>>>>> else: >>>>>> # Test entry: >>>>>> if Test == True: >>>>>> logger.debug(name + ' already exists') >>>>>> >>>>>> return logger >>>>>> >>>>>> -- >>>>>> Resources: >>>>>> - http://web2py.com >>>>>> - http://web2py.com/book (Documentation) >>>>>> - http://github.com/web2py/web2py (Source code) >>>>>> - https://code.google.com/p/web2py/issues/list (Report Issues) >>>>>> --- >>>>>> You received this message because you are subscribed to the Google >>>>>> Groups "web2py-users" group. >>>>>> To unsubscribe from this group and stop receiving emails from it, >>>>>> send an email to web2py+un...@googlegroups.com. >>>>>> To view this discussion on the web visit >>>>>> https://groups.google.com/d/msgid/web2py/c9b3c32c-6cfc-4b5f-9894-a62d16898ea5n%40googlegroups.com >>>>>> <https://groups.google.com/d/msgid/web2py/c9b3c32c-6cfc-4b5f-9894-a62d16898ea5n%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>>> . >>>>>> >>>>> -- >>>> Resources: >>>> - http://web2py.com >>>> - http://web2py.com/book (Documentation) >>>> - http://github.com/web2py/web2py (Source code) >>>> - https://code.google.com/p/web2py/issues/list (Report Issues) >>>> --- >>>> You received this message because you are subscribed to the Google >>>> Groups "web2py-users" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to web2py+un...@googlegroups.com. >>>> >>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/web2py/4af7b1b3-1161-4252-80fe-0f89e125db82n%40googlegroups.com >>>> <https://groups.google.com/d/msgid/web2py/4af7b1b3-1161-4252-80fe-0f89e125db82n%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>> -- > Resources: > - http://web2py.com > - http://web2py.com/book (Documentation) > - http://github.com/web2py/web2py (Source code) > - https://code.google.com/p/web2py/issues/list (Report Issues) > --- > You received this message because you are subscribed to the Google Groups > "web2py-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to web2py+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/web2py/fa59697a-1c8c-461f-b3e8-472f8eb12c94n%40googlegroups.com > <https://groups.google.com/d/msgid/web2py/fa59697a-1c8c-461f-b3e8-472f8eb12c94n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/CACWMBMMOtCJGgXEanK0Bz_FGsCenDA_nM%3Dzfp7Y-ao%2B8_cFhEw%40mail.gmail.com.