Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write .lgd-nfy file to tmp? #22

Closed
CamDavidsonPilon opened this issue Oct 12, 2023 · 1 comment
Closed

Write .lgd-nfy file to tmp? #22

CamDavidsonPilon opened this issue Oct 12, 2023 · 1 comment

Comments

@CamDavidsonPilon
Copy link

Preface: I'm still learning about your library

When using your library in a Python script embedded in a systemd service, I am hitting the following error on start up:

Oct 12 17:58:47 leaderbw pio[1674]: 2023-10-12 17:58:47 xCreatePipe: Can't set permissions (436) for //.lgd-nfy0, No such file or directory
... [omitted]...
Oct 12 17:58:47 leaderbw pio[1674]:     import lgpio
Oct 12 17:58:47 leaderbw pio[1674]:   File "/usr/lib/python3/dist-packages/lgpio.py", line 562, in <module>
Oct 12 17:58:47 leaderbw pio[1674]:     _notify_thread = _callback_thread()
Oct 12 17:58:47 leaderbw pio[1674]:                      ^^^^^^^^^^^^^^^^^^
Oct 12 17:58:47 leaderbw pio[1674]:   File "/usr/lib/python3/dist-packages/lgpio.py", line 504, in __init__
Oct 12 17:58:47 leaderbw pio[1674]:     self._file = open('.lgd-nfy{}'.format(self._notify), 'rb')
Oct 12 17:58:47 leaderbw pio[1674]:                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 12 17:58:47 leaderbw pio[1674]: FileNotFoundError: [Errno 2] No such file or directory: '.lgd-nfy-3'

Looking into the Python code, the callback_thread tries to write the notify file to the current dir. Permissions errors can occur, like above. Does it make sense to write this file to /tmp (or tempdir()), since all users can write to it?


My solution is to modify the .service to set the working directory to somewhere I can write.

@CamDavidsonPilon
Copy link
Author

Ah, I just saw issue #12, and the solution LG_WD=/tmp. Closing this as that issue tracks this issue better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant