A simple wrapper for kqueue VNODE (for now) functionality to be asyncio compatible.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
John-Mark Gurney 9e082a8487 add sample program testing if a directory can be watched 9 mesi fa
aiokq add a wrapper around kqueue for VNODE that is asyncio friendly. 9 mesi fa
misc add sample program testing if a directory can be watched 9 mesi fa
.gitignore add a wrapper around kqueue for VNODE that is asyncio friendly. 9 mesi fa
LICENSE.txt add a wrapper around kqueue for VNODE that is asyncio friendly. 9 mesi fa
Makefile add a wrapper around kqueue for VNODE that is asyncio friendly. 9 mesi fa
README.md add a wrapper around kqueue for VNODE that is asyncio friendly. 9 mesi fa
requirements.txt add a wrapper around kqueue for VNODE that is asyncio friendly. 9 mesi fa
setup.py add a wrapper around kqueue for VNODE that is asyncio friendly. 9 mesi fa

README.md

aiokq

This is a module to make select.kqueue module compatible with programs that use asyncio.

The core of kqueue is already implemented via the core asyncio, but other parts of kqueue, like EVFILT_VNODE and EVFILT_PROC are not. This module is currently limited to supporting basic EVFILT_VNODE functionality.

Sample Usage

To watch a file for modification:

fp = open(fname)
async with aiokq.watch_file(fp) as wf:
	while True:
		data = fp.read()
		# do some work on data

		# wait for a modification
		await wf()

The with symantics is required in order to address the race where a write is issued between the registration and the time that you do the read. There is the possibility that a wakeup happens and there are no modifications due to this race.