3

I try to make a Python application read data from a shared memory type section. The location of the shared memory is \Sessions\1\BaseNamedObjects\ObjectName.

Do I need to use mmap for read this? If yes, how can I open this shared memory? Like open("\Sessions\1\BaseNamedObjects\ObjectName", "r+b")?

I tried this, but it reported an invalid argument.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • I tried with fd=os.open('\BasedNamedObjects\ObjectName', os.O_RDONLY) but i have error 'FileNotFoundError' – DOO YOUNG KIM Jun 08 '15 at 01:20
  • Try to escape backslashes `"\\Sessions\\1\\BaseNamedObjects\\ObjectName"`, or use raw string literals `r"\Sessions\1\BaseNamedObjects\ObjectName"`. (`"\1" == "\x01" == chr(1)`) – falsetru Jun 08 '15 at 01:35
  • I tried with 'r"\Sessions\1\BasedNamedObecjects\ObjectName"' but it's still same.. – DOO YOUNG KIM Jun 08 '15 at 01:39
  • Q1, Does "\Sessions\1\BaseNamedObjects\ObjectName" actually exist on your file system? If not you can't open it. – mhawke Jun 09 '15 at 09:52
  • Q2. If you are using QSharedMemory as tagged, why are you trying to use mmap? This _might_ work in windows, but what created the shared object? A QT application? – mhawke Jun 09 '15 at 11:12

0 Answers0