OpenAdapt
OpenAdapt copied to clipboard
[Bug]: processes aren't killed after exiting recording
Describe the bug
Upon exiting recording:
/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/multiprocessing/resource_tracker.py:224: UserWarning: resource_tracker: There appear to be 32 leaked semaphore objects to clean up at shutdown
To Reproduce
python -m openadapt.record
...
<ctrl>+c
TODO: figure out more precise steps to reproduce
@abrichr
When you have a moment, please share additional info on how to reproduce.
I was unable to fix this bug, however, I did notice a couple things
- event_q is the only queue that is not empty at the end of the
recordfunction - as noted in queue.py's docstrings for qsize and empty, race conditions may cause those functions to be inaccurate so we could use Queue.join() to ensure the queue is empty
- Queue.join() blocks until all items in the Queue have been gotten and processed and requires Queue.task_done() to be called after getting each item in the queue
- even after ensuring event_q is empty, there were still the same number of leaked semaphores (40 in my case)
- changing the maxsize of the queues to 1, 3, 1000, and 100 also didn't help