1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-17 01:22:19 +03:00

Make replay file line-buffered ()

Squashed commit of the following:

commit d42bb0add648ba52e56dd03a48ef9e1d09fdbda0
Author: Jonathan Harris <jonathan@marginal.org.uk>
Date:   Fri Sep 13 19:36:14 2019 +0100

    Use line buffering when creating replay file.

commit 1b6e499e2c306b66708a9fd210d1db1771c4c78f
Author: Athanasius <github@miggy.org>
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.
This commit is contained in:
Jonathan Harris 2019-09-13 19:42:33 +01:00
parent 02d4da30d5
commit 09de1adc91

@ -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: