From 09de1adc913026087564b3cd20db2c584a31cfea Mon Sep 17 00:00:00 2001 From: Jonathan Harris Date: Fri, 13 Sep 2019 19:42:33 +0100 Subject: [PATCH] Make replay file line-buffered (#448) Squashed commit of the following: commit d42bb0add648ba52e56dd03a48ef9e1d09fdbda0 Author: Jonathan Harris Date: Fri Sep 13 19:36:14 2019 +0100 Use line buffering when creating replay file. commit 1b6e499e2c306b66708a9fd210d1db1771c4c78f Author: Athanasius Date: Thu Sep 12 17:30:59 2019 +0100 Use line buffering for replay file. By default it takes a lot of data being written to the file for it to be flushed. Or exiting EDMC. So, let's reduce the chances of data loss. --- plugins/eddn.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/eddn.py b/plugins/eddn.py index a4cc7c51..6359121b 100644 --- a/plugins/eddn.py +++ b/plugins/eddn.py @@ -59,12 +59,12 @@ class EDDN: try: try: # Try to open existing file - self.replayfile = open(filename, 'r+') + self.replayfile = open(filename, 'r+', buffering=1) except: if exists(filename): raise # Couldn't open existing file else: - self.replayfile = open(filename, 'w+') # Create file + self.replayfile = open(filename, 'w+', buffering=1) # Create file if sys.platform != 'win32': # open for writing is automatically exclusive on Windows lockf(self.replayfile, LOCK_EX|LOCK_NB) except: