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

watchdog.utils.platform.is_bsd() is always false #320

Closed
magv opened this issue Jun 9, 2015 · 3 comments
Closed

watchdog.utils.platform.is_bsd() is always false #320

magv opened this issue Jun 9, 2015 · 3 comments

Comments

@magv
Copy link

magv commented Jun 9, 2015

Hi. Currently watchdog uses this code to detect current platform:

def get_platform_name():
    if sys.platform.startswith("win"):
        return PLATFORM_WINDOWS
    elif sys.platform.startswith('darwin'):
        return PLATFORM_DARWIN
    elif sys.platform.startswith('linux'):
        return PLATFORM_LINUX
    elif sys.platform.startswith('bsd'):
        return PLATFORM_BSD
    else:
        return PLATFORM_UNKNOWN

This code doesn't really work. On FreeBSD 10 sys.platform is set to 'freebsd10', and 'freebsd10'.starswith('bsd') is false, so this code always returns PLATFORM_UNKNOWN. As a consequence, the default observer on FreeBSD is the polling-based one, not the kqueue-based one.

Could you change the platform detection to something like the following instead?

def get_platform_name():
    if 'darwin' in sys.platform:
        return PLATFORM_DARWIN
    elif 'win' in sys.platform:
        return PLATFORM_WINDOWS
    elif 'linux' in sys.platform:
        return PLATFORM_LINUX
    elif 'bsd' in sys.platform:
        return PLATFORM_BSD
    else:
        return PLATFORM_UNKNOWN
@simplytunde
Copy link

Seems like the same issue has been pointed out in issue #312.

@magv
Copy link
Author

magv commented Jun 17, 2015

Yeah, it's the same issue (I did not notice it initially). There's been no response to that issue in two months though...

@magv
Copy link
Author

magv commented Jun 17, 2015

Also note that kqueue observer is somewhat broken: it does not create a listener for the top level directory (DirectorySnapshot only lists the children and skips the parent), so if new files are added to it, the observer will not see them. This was not an issue before, because that observer was never used, but if platform detection is to be fixed, the observer should be fixed as well.

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

2 participants