OpenAdapt icon indicating copy to clipboard operation
OpenAdapt copied to clipboard

[Bug]: processes aren't killed after exiting recording

Open abrichr opened this issue 2 years ago • 2 comments

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 avatar Jul 07 '23 15:07 abrichr

@abrichr

When you have a moment, please share additional info on how to reproduce.

ayewo avatar Jul 28 '23 11:07 ayewo

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 record function
  • 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

dianzrong avatar Aug 08 '23 23:08 dianzrong