Skip to content

AttributeError: module 'pidfile' has no attribute 'PIDFile' #15

@Jachimo

Description

@Jachimo

This may be user error vs. a bug, but if so maybe a documentation update could be made to explain what I'm doing wrong?

import pidfile
import sys
import time

def main():
    time.sleep(5)

if __name__ == '__main__':
    print('Initializing process')
    try:
        with pidfile.PIDFile('/var/run/myprogram.pid'):
            print('Creating PID file...')
            main()
    except pidfile.AlreadyRunningError:
        print('Program already running!')
        sys.exit(1)
    sys.exit(0)

Based on the documentation, I expected the above to work, but it doesn't. Instead, I get AttributeError: module 'pidfile' has no attribute 'PIDFile'.

This is with Python 3.9.2 on Linux 5.15.84, aarch64 (Raspberry Pi), everything is straight from the Raspbian repos on a clean installation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions