Hi,
I’d like to read .map shared memory files in my pyROOT script. However, if I try to call TMapFile.Create(‘file.map’), I get the following error message:
Error in TMapFile::TMapFile: no memory mapped file capability available
Use rootn.exe or link application against “-lNew”
Well, if it was in an app or within root, I would do what it says, but what am I supposed to do in a python script? Is there a possibility to use TMapFile from within pyROOT? Should I load some additional library (but how?) in the script? I need it badly, bc I want to be able to read constantly updated histograms from a mapfile that contains data from online monitoring in my experiment. And from what I know, simultaneous read and write operations are only supported by TMapFiles.
That doesn’t seem to change anything:( The code is as follows:
import ROOT
from ctypes import *
libNew = CDLL("libNew.so") #I added this line following your advice
from ROOT import TFile, TH1F, TH1D, TMapFile
f = TMapFile.Create('backend/histograms.map');
hist = f.Get('trig_t2_2h');
histname = hist.GetName()
What I get is:
Error in <TMapFile::TMapFile>: no memory mapped file capability available
Use rootn.exe or link application against "-lNew"
Traceback (most recent call last):
File "root1.py", line 19, in <module>
histname = hist.GetName()
ReferenceError: attempt to access a null-pointer
Any further ideas? Maybe I should somehow reference the TMapFile type using ctypes? But I don’t know how.
$ LD_PRELOAD=$ROOTSYS/lib/libNew.so python
>>> from ROOT import TFile, TH1F, TH1D, TMapFile
>>> f = TMapFile.Create('histograms.map', 'RECREATE');
This doesn’t:
$ python
>>> from ctypes import *
>>> libNew = CDLL("libNew.so") #I added this line following your advice
>>> from ROOT import TFile, TH1F, TH1D, TMapFile
Fatal in <operator delete>: storage area overwritten
aborting
I’m trying to find out what’s going wrong and how to fix that.
Hi Axel,
thanks a lot for trying to help!
Just to clarify:
$ LD_PRELOAD=$ROOTSYS/lib/libNew.so python
means you set LD_PRELOAD environment variable to “$ROOTSYS/lib/libNew.so” and then run the script? Hm, I tried that (I’m using ROOT 5.34/36 on a Mac) but it didn’t work in my case… (nothing’s changed , error message is the same).
If using CDLL, make sure to add ctypes.RTLD_GLOBAL as a second argument, and note that it does not respect LD_LIBRARY_PATH on Linux (only on Mac; is/was disagreement among the developers).
You’re using ROOT anyway, so go with: ROOT.gSystem.Load("libNew").