trbs / pid

Pidfile featuring stale detection and file-locking, can also be used as context-manager or decorator
https://pypi.python.org/pypi/pid/
Apache License 2.0
102 stars 26 forks source link

Better API support for querying #27

Open mike1158 opened 5 years ago

mike1158 commented 5 years ago

It would be nice to add some better API support for querying the process status.

For example, if there is no extant pidfile, the .check() method throws an IOError due to lack of write access. I suppose this could be interpreted as "file does not exist", but it's not very clear.

It would also be nice to be able to get access to the numeric pid if it exists. As it is now, if a process is already running, calling .check() throws an exception. The error message does contain the pid of the running process, but unless I'm missing something, there's no way to access it without parsing it out of the error message.

trbs commented 5 years ago

Think this is a very good idea.

Do you think you might be able to create a PR with some additional methods for querying the status ?

trbs commented 4 years ago

https://pypi.org/project/pid/3.0.3/ adds support for retrieving the numeric pid value from PidFileAlreadyRunningError exception.