Flush shared memory file before attempting to map

This avoids the error "ValueError: mmap length is greater than file size"
on OSX. (see #730)
This commit is contained in:
Luke Campagnola 2018-09-11 07:14:28 -07:00
parent 9aaae8d5dc
commit 839ad486f8

View File

@ -152,6 +152,7 @@ class Renderer(GraphicsView):
else:
self.shmFile = tempfile.NamedTemporaryFile(prefix='pyqtgraph_shmem_')
self.shmFile.write(b'\x00' * (mmap.PAGESIZE+1))
self.shmFile.flush()
fd = self.shmFile.fileno()
self.shm = mmap.mmap(fd, mmap.PAGESIZE, mmap.MAP_SHARED, mmap.PROT_WRITE)
atexit.register(self.close)