Skip to content

Commit

Permalink
Dump only on processor 0
Browse files Browse the repository at this point in the history
- Some combination of linux and Python 3.8 fails to close /dev/null
  on other processors.
- Writing on only one file deadlocks in
  `fipy.meshes.representations.gridRepresentation._GridRepresentation._test`:
  https://app.circleci.com/jobs/github/usnistgov/fipy/1226
  https://app.circleci.com/jobs/github/usnistgov/fipy/1225
  https://app.circleci.com/jobs/github/usnistgov/fipy/1217
  https://travis-ci.org/usnistgov/fipy/jobs/627999300
- Stipulate binary

  Avoid doubling memory with `dumps()`,
  but prevent `/dev/null` closure problem
  • Loading branch information
guyer committed Jan 27, 2020
1 parent 1bc0ac4 commit 5ddeb08
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fipy/tools/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ def write(data, filename = None, extension = '', communicator=parallelComm):
(f, _filename) = tempfile.mkstemp(extension)
else:
(f, _filename) = (None, filename)
fileStream = gzip.GzipFile(filename = _filename, mode = 'w', fileobj = None)
fileStream = gzip.GzipFile(filename=_filename, mode='wb', fileobj=None)
else:
fileStream = open(os.devnull, mode='w')
fileStream = open(os.devnull, mode='wb')
(f, _filename) = (None, os.devnull)

pickle.dump(data, fileStream, 0)
Expand All @@ -78,7 +78,7 @@ def read(filename, fileobject=None, communicator=parallelComm, mesh_unmangle=Fal
Whether to correct improper pickling of non-uniform meshes (ticket:243)
"""
if communicator.procID == 0:
fileStream = gzip.GzipFile(filename = filename, mode = 'r', fileobj = None)
fileStream = gzip.GzipFile(filename=filename, mode='r', fileobj=None)
data = fileStream.read()
fileStream.close()
if fileobject is not None:
Expand Down

0 comments on commit 5ddeb08

Please sign in to comment.