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

prevent shutdown from hanging on Windows #104

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JayDeezus
Copy link
Contributor

@JayDeezus JayDeezus commented Aug 20, 2024

on my system (Windows) queue.get() with no arguments will just hang during shutdown. I'm attempting to preserve the blocking behavior of audio_queue.get() with arguments True and 1.

  • True - the call still blocks, preserving your existing behavior
  • 1 - blocks for at most 1 second

See https://docs.python.org/3/library/queue.html#queue.Queue.get for details. Specifically:

"""
Prior to 3.0 on POSIX systems, and for all versions on Windows, if block is true and timeout is None, this operation goes into an uninterruptible wait on an underlying lock. This means that no exceptions can occur, and in particular a SIGINT will not trigger a KeyboardInterrupt.
"""

on my system (Windows) queue.get() with no arguments will just hang during shutdown.  I'm attempting to preserve the blocking behavior of audio_queue.get() with arguments True and 1.
* True - the call still blocks, preserving your existing behavior
* 1 - blocks for at most 1 second

See https://docs.python.org/3/library/queue.html#queue.Queue.get for details.  Specifically:

"""
Prior to 3.0 on POSIX systems, and for all versions on Windows, if block is true and timeout is None, this operation goes into an uninterruptible wait on an underlying lock. This means that no exceptions can occur, and in particular a SIGINT will not trigger a KeyboardInterrupt.
"""
@JayDeezus JayDeezus changed the title Update audio_recorder.py prevent shutdown from hanging on Windows Aug 20, 2024
@JayDeezus JayDeezus closed this Aug 20, 2024
@JayDeezus JayDeezus deleted the patch-1 branch August 20, 2024 14:07
@JayDeezus
Copy link
Contributor Author

please disregard this request, as I did not test this code enough and am still experiencing some breakage.

@JayDeezus
Copy link
Contributor Author

I think my suggested edit is still valid, as without the arguments in queue.get(...) that line will hang on windows and not process a KeyboardInterrupt per the method documentation comments. I was testing my script this morning where I made a subclass inheriting AudioToTextRecorder and overloaded _recording_worker with my edits and had an inconsistent case of the reader process not terminating in time, so I wanted to run the script a few times to see if I could get some insight as to why this was happening.

@JayDeezus JayDeezus restored the patch-1 branch August 20, 2024 14:19
@JayDeezus JayDeezus reopened this Aug 20, 2024
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

Successfully merging this pull request may close these issues.

1 participant