TonyWhitley / pyRfactor2SharedMemory

Python library for accessing rFactor 2's shared memory
MIT License
5 stars 5 forks source link

AttributeError: 'SimInfoAPI' object has no attribute '_rf2_tele' #9

Open thoraxe opened 1 year ago

thoraxe commented 1 year ago
python ./sharedMemoryAPI.py

Traceback (most recent call last):
  File "./sharedMemoryAPI.py", line 336, in <module>
    test_main()
  File "./sharedMemoryAPI.py", line 236, in test_main
    info = SimInfoAPI()
  File "./sharedMemoryAPI.py", line 30, in __init__
    rF2data.SimInfo.__init__(self)
  File "/home/thoraxe/Red_Hat/openshift/pyRfactor2SharedMemory/rF2data.py", line 697, in __init__
    self._rf2_tele = mmap.mmap(0, ctypes.sizeof(rF2Telemetry), "$rFactor2SMMP_Telemetry$")
TypeError: an integer is required (got type str)
Exception ignored in: <function SimInfoAPI.__del__ at 0x7fce248744d0>
Traceback (most recent call last):
  File "./sharedMemoryAPI.py", line 211, in __del__
    self.close()
  File "./sharedMemoryAPI.py", line 204, in close
    self._rf2_tele.close()
AttributeError: 'SimInfoAPI' object has no attribute '_rf2_tele'

Similarly:

python rF2data.py 
Traceback (most recent call last):
  File "rF2data.py", line 718, in <module>
    info = SimInfo()
  File "rF2data.py", line 697, in __init__
    self._rf2_tele = mmap.mmap(0, ctypes.sizeof(rF2Telemetry), "$rFactor2SMMP_Telemetry$")
TypeError: an integer is required (got type str)
Exception ignored in: <function SimInfo.__del__ at 0x7f17ee8c2cb0>
Traceback (most recent call last):
  File "rF2data.py", line 714, in __del__
    self.close()
  File "rF2data.py", line 707, in close
    self._rf2_tele.close()
AttributeError: 'SimInfo' object has no attribute '_rf2_tele'

It's not clear why or what's wrong.

python --version
Python 3.7.16

pip list
Package           Version
----------------- -------
astroid           2.2.5  
behave            1.2.6  
colorama          0.4.1  
isort             4.3.21 
lazy-object-proxy 1.4.2  
mccabe            0.6.1  
parse             1.12.0 
parse-type        0.4.2  
pip               10.0.1 
psutil            5.7.0  
pylint            2.3.1  
setuptools        39.0.1 
six               1.12.0 
typed-ast         1.4.0  
wrapt             1.11.2 
thoraxe commented 1 year ago

The above was running on Linux, so it's entirely possible that's the problem. Although rF2 does run on Linux.

TonyWhitley commented 1 year ago

Sorry, the notification email was filtered away so I had no idea about this. I can't promise when I'll look at this code again but at least I know it needs attention now.

s-victor commented 1 year ago

Hi, if I'm not mistaken, this issue was fixed in those two PR by berarma https://github.com/s-victor/pyRfactor2SharedMemory/pull/1 & https://github.com/s-victor/pyRfactor2SharedMemory/pull/3 , which is by separating windows & linux to each of their own mmap parameters (and 2nd PR creates mmap files required under linux), since two system using two different mmap), there is further improvements in the following fork used by tinypedal (see rF2MMap class section): https://github.com/s-victor/pyRfactor2SharedMemory/blob/master/sim_info_sync.py

Hope helps.