Skip to content

windows support for non-blocking tailing #12

Description

@sponsoredlinks

Thanks for the library, it's great. Just a small one for windows users getting the following, this can be fixed by removing the non-block flag in the os.open call. Not sure if there is a better way but this appears to fix the problem for me, and works for tailing multiple files

Patch:

import sys

is_windows = sys.platform == 'win32'
fh = os.fdopen(os.open(path, os.O_RDONLY | (0 if is_windows else os.O_NONBLOCK)))

Error:

Traceback (most recent call last):
File "userfile.py", line 6, in
mt = multitail2.MultiTail(glob_str)
File "C:\Python310\lib\site-packages\multitail2.py", line 152, in init
self._rescan(skip_to_end = skip_to_end)
File "C:\Python310\lib\site-packages\multitail2.py", line 177, in _rescan
self._tailedfiles[path] = TailedFile(path, skip_to_end = skip_to_end, offset = self._offsets.get(path, None))
File "C:\Python310\lib\site-packages\multitail2.py", line 16, in init
self._open(path, skip_to_end, offset)
File "C:\Python310\lib\site-packages\multitail2.py", line 30, in _open
fh = os.fdopen(os.open(path, os.O_RDONLY | os.O_NONBLOCK))
AttributeError: module 'os' has no attribute 'O_NONBLOCK'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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