Merge pull request #304 from cboulay/osx_mremap
OSX RemoteGrahpics.py: Add shared mem file open and close to get around no mremap.
This commit is contained in:
commit
f49554d063
@ -77,6 +77,10 @@ class RemoteGraphicsView(QtGui.QWidget):
|
|||||||
if sys.platform.startswith('win'):
|
if sys.platform.startswith('win'):
|
||||||
self.shmtag = newfile ## on windows, we create a new tag for every resize
|
self.shmtag = newfile ## on windows, we create a new tag for every resize
|
||||||
self.shm = mmap.mmap(-1, size, self.shmtag) ## can't use tmpfile on windows because the file can only be opened once.
|
self.shm = mmap.mmap(-1, size, self.shmtag) ## can't use tmpfile on windows because the file can only be opened once.
|
||||||
|
elif sys.platform == 'darwin':
|
||||||
|
self.shmFile.close()
|
||||||
|
self.shmFile = open(self._view.shmFileName(), 'r')
|
||||||
|
self.shm = mmap.mmap(self.shmFile.fileno(), size, mmap.MAP_SHARED, mmap.PROT_READ)
|
||||||
else:
|
else:
|
||||||
self.shm = mmap.mmap(self.shmFile.fileno(), size, mmap.MAP_SHARED, mmap.PROT_READ)
|
self.shm = mmap.mmap(self.shmFile.fileno(), size, mmap.MAP_SHARED, mmap.PROT_READ)
|
||||||
self.shm.seek(0)
|
self.shm.seek(0)
|
||||||
@ -193,6 +197,13 @@ class Renderer(GraphicsView):
|
|||||||
## it also says (sometimes) 'access is denied' if we try to reuse the tag.
|
## it also says (sometimes) 'access is denied' if we try to reuse the tag.
|
||||||
self.shmtag = "pyqtgraph_shmem_" + ''.join([chr((random.getrandbits(20)%25) + 97) for i in range(20)])
|
self.shmtag = "pyqtgraph_shmem_" + ''.join([chr((random.getrandbits(20)%25) + 97) for i in range(20)])
|
||||||
self.shm = mmap.mmap(-1, size, self.shmtag)
|
self.shm = mmap.mmap(-1, size, self.shmtag)
|
||||||
|
elif sys.platform == 'darwin':
|
||||||
|
self.shm.close()
|
||||||
|
self.shmFile.close()
|
||||||
|
self.shmFile = tempfile.NamedTemporaryFile(prefix='pyqtgraph_shmem_')
|
||||||
|
self.shmFile.write(b'\x00' * (size + 1))
|
||||||
|
self.shmFile.flush()
|
||||||
|
self.shm = mmap.mmap(self.shmFile.fileno(), size, mmap.MAP_SHARED, mmap.PROT_WRITE)
|
||||||
else:
|
else:
|
||||||
self.shm.resize(size)
|
self.shm.resize(size)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user