Perform any cleanup actions in the logging system (e.g. flushing buffers). Should be called at application exit.
(handlerList=_handlerList)
| 2235 | root.manager._clear_cache() |
| 2236 | |
| 2237 | def shutdown(handlerList=_handlerList): |
| 2238 | """ |
| 2239 | Perform any cleanup actions in the logging system (e.g. flushing |
| 2240 | buffers). |
| 2241 | |
| 2242 | Should be called at application exit. |
| 2243 | """ |
| 2244 | for wr in reversed(handlerList[:]): |
| 2245 | #errors might occur, for example, if files are locked |
| 2246 | #we just ignore them if raiseExceptions is not set |
| 2247 | try: |
| 2248 | h = wr() |
| 2249 | if h: |
| 2250 | try: |
| 2251 | h.acquire() |
| 2252 | # MemoryHandlers might not want to be flushed on close, |
| 2253 | # but circular imports prevent us scoping this to just |
| 2254 | # those handlers. hence the default to True. |
| 2255 | if getattr(h, 'flushOnClose', True): |
| 2256 | h.flush() |
| 2257 | h.close() |
| 2258 | except (OSError, ValueError): |
| 2259 | # Ignore errors which might be caused |
| 2260 | # because handlers have been closed but |
| 2261 | # references to them are still around at |
| 2262 | # application exit. |
| 2263 | pass |
| 2264 | finally: |
| 2265 | h.release() |
| 2266 | except: # ignore everything, as we're shutting down |
| 2267 | if raiseExceptions: |
| 2268 | raise |
| 2269 | #else, swallow |
| 2270 | |
| 2271 | #Let's try and shutdown automatically on application exit... |
| 2272 | import atexit |