upkie / vulp

Robot/simulation switch for the mjbots stack
Apache License 2.0
61 stars 4 forks source link

module 'posix_ipc' has no attribute 'O_RDWR' #21

Closed ubgk closed 1 year ago

ubgk commented 1 year ago

I suspect this could require non-trivial modifications to some parts of vulp. When I run tests now vulp/spine/tests/spine_interface_test.py throws an AttributeError: module 'posix_ipc' has no attribute 'O_RDWR': (cf. error.log).

O_RDWR is defined between guards here, so maybe macOS doesn't implement POSIX message queues?

Originally posted by @boragokbakan in https://github.com/tasts-robots/vulp/issues/15#issuecomment-1531427156

stephane-caron commented 1 year ago

The version of posix-ipc we use is from another repository: https://github.com/osvenskan/posix_ipc This is the one we get when installing from PyPI. (The repository you linked to is also called posix_ipc, which is confusing :sweat_smile: In case of doubt, go to PyPI first then follow the links to GitHub.)

Your point is still valid though :+1:

https://github.com/osvenskan/posix_ipc/blob/00e59860bed2c6093f3af366c004f1d0adb93b90/posix_ipc_module.c#L2479-L2484

ubgk commented 1 year ago

Oh my bad, nice catch. No idea how I got to the wrong repo. 😅

Do you think this is an easy fix though?

stephane-caron commented 1 year ago

As far as I recall Vulp does not use message queues. We open a shared-memory file with shm_open (C) / posix_ipc.SharedMemory (Python). We should be able to do without the posix-ipc dependency and use the Python standard library instead: multiprocessing.shared_memory

But judging from this line, there may be a faster fix: setting flags to zero and read_only=False should work on both Linux and macOS.

stephane-caron commented 1 year ago

@boragokbakan I tried the second option and it performs as before on Linux. We don't rely on posix_ipc.O_RDWR any more so I expect this issue is fixed, feel free to re-open otherwise.