-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Async feature implementation using threading library #28
Conversation
Fix issues in decorators
* Async bugs: call the play function async from test script * Test script: more intuitive example of test script
* Async feature: Now user will get a handling thread which then could be used for waiting for the sound playing to be ended or do other tasks in the meantime. * Update documentations
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## dev #28 +/- ##
============================================
- Coverage 100.00% 69.13% -30.87%
============================================
Files 3 3
Lines 56 81 +25
Branches 4 7 +3
============================================
Hits 56 56
- Misses 0 24 +24
- Partials 0 1 +1
☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NimaSamadi007 Well done 💯
This approach looks good to me!
-
I think it would be better to return
proc
in the__play_sync_linux
function instead of declaring a new function like__play_non_blocking_linux
. This work will prevent future duplications. -
It seems there is a minor issue in import/call of the
__cleanup_processes
function in__init__.py
-
Continue your work for other platforms
Good luck 🔥
Thanks 🙏, that's great.
|
…- Finish Linux implementation * __non_blocking_play() is removed * cleanup_processes function name changed to make sure it's imported * Linux implementation completed and tested
Hello all. I implemented the Windows async feature and applied the requested codebase changes. Please help to check it. I don't have access to a MacOS-based device. So, I couldn't implement the async feature for MacOS. Should I install it in a virtualized environment and work on it or do you have any other suggestions? I haven't worked with MacOS before so I don't know if it's even possible to do this. |
Thanks Nima. You just needed to implement macOS by replacing |
I implemented the macOS async feature similar to Linux implementation. By the way, in Windows, you can specify a flag to play the sound in async mode and you don't need to worry about the underlying process getting killed or not and everything is handled in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Nima. It looks good to me.
Just remove test/__init__.py
and test/main.py
. We will add tests for it after this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
Due to the previous inconsistencies of async feature implementation, the
threading
library is used to implement the async-like sound-playing feature. Tests are provided in thetest
directory. Github build fails due to some issues with thefunction_test.py
script which I'm not sure why.It seems that when the parent thread of the subprocess is dead, its child process doesn't die automatically. In other words, in async mode, if the user program ends before the sound playing is finished, the user can hear the voice although the program is terminated. Therefore, it seems that we need some sort of cleanup procedure to kill/terminate these child threads so they don't end up being zombie processes. The best way to do this is to use class destructors but as of now, the code is more function-oriented rather than object-oriented. For now, I used Python's
atexit
library to run the cleanup procedure. Any other comments are welcome!