Last active
February 15, 2016 20:07
-
-
Save veaviticus/fb1ad2606decd65a209b to your computer and use it in GitHub Desktop.
LOGBOOK #136 RotatingFileHandler gives ValueError: I/O operation on closed file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Windows 7 x64 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| WE NEED TO FILL UP THE FILE | |
| WITH 100 BYTES OF STUFF | |
| SO THAT WHEN LOGBOOK TRIES TO RUN | |
| IT NEEDS TO ROTATE THE FILE | |
| Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce consequat, ipsum at interdum congue, eros sapien sodales mi, at iaculis eros mauris sit amet nulla. Aliquam ultricies vehicula consectetur. Curabitur in eleifend eros, ut dictum elit. In metus mauris, convallis sit amet ullamcorper in, eleifend ultrices eros. Pellentesque vitae metus libero. In a rhoncus ligula. Nulla euismod suscipit augue, a rhoncus nunc tempor id. Donec dictum est at lobortis aliquam. Pellentesque nibh felis, aliquet vitae nulla ac, convallis eleifend nulla. Phasellus ut dignissim mi. Mauris auctor orci eget lorem interdum fermentum. Suspendisse tristique tortor nec nulla congue, id ullamcorper nibh fringilla. Nulla tempor massa non quam tempus consequat. Quisque sit amet metus tortor. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [py3] D:\Veaviticus\github\logbook_error>python run.py | |
| * Running on http://0.0.0.0:5001/ (Press CTRL+C to quit) | |
| * Restarting with stat | |
| * Debugger is active! | |
| * Debugger pin code: 940-711-594 | |
| Traceback (most recent call last): | |
| File "C:\Miniconda3\envs\py3\lib\site-packages\logbook\handlers.py", line 212, in handle | |
| self.emit(record) | |
| File "C:\Miniconda3\envs\py3\lib\site-packages\logbook\handlers.py", line 761, in emit | |
| self.perform_rollover() | |
| File "C:\Miniconda3\envs\py3\lib\site-packages\logbook\handlers.py", line 752, in perform_rollover | |
| rename(self._filename, self._filename + '.1') | |
| File "C:\Miniconda3\envs\py3\lib\site-packages\logbook\helpers.py", line 167, in rename | |
| os.rename(src, dst) | |
| PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'output.log' -> 'output.log.1' | |
| Logged from file D:\Veaviticus\github\logbook_error\run.py, line 16 | |
| 127.0.0.1 - - [15/Feb/2016 14:02:09] "GET /index HTTP/1.1" 200 - | |
| 127.0.0.1 - - [15/Feb/2016 14:02:09] "GET /favicon.ico HTTP/1.1" 404 - | |
| Traceback (most recent call last): | |
| File "C:\Miniconda3\envs\py3\lib\site-packages\logbook\handlers.py", line 212, in handle | |
| self.emit(record) | |
| File "C:\Miniconda3\envs\py3\lib\site-packages\logbook\handlers.py", line 760, in emit | |
| if self.should_rollover(record, len(msg)): | |
| File "C:\Miniconda3\envs\py3\lib\site-packages\logbook\handlers.py", line 738, in should_rollover | |
| self.stream.seek(0, 2) | |
| ValueError: I/O operation on closed file. | |
| Logged from file D:\Veaviticus\github\logbook_error\run.py, line 16 | |
| 127.0.0.1 - - [15/Feb/2016 14:02:11] "GET /index HTTP/1.1" 200 - |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Flask==0.10.1 | |
| Logbook==0.12.5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import flask | |
| import logbook | |
| handler = logbook.RotatingFileHandler("output.log", level="DEBUG", max_size=100) | |
| handler.format_string = '[{record.time}] [{record.level_name}] [{record.channel}] {record.message}' | |
| handler.push_application() | |
| app = flask.Flask(__name__) | |
| LOGGER = logbook.Logger('Routes') | |
| @app.route('/') | |
| @app.route('/index', methods=['GET']) | |
| def main(): | |
| LOGGER.debug("FOO") | |
| return "HELLO WORLD" | |
| app.run( | |
| debug=True, | |
| host= '0.0.0.0', | |
| port=5001 | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment