Depreciation Warning from asyncio in Command and OProc _init
amoffat opened this issue · comments
This event loop code should only run if the user is using a command's asyncio features
Discussed in #682
Originally posted by Hos73 June 14, 2023
sh package version: 2.0.4
I was checking for Depreciations in my code and stumbled across depreciations in the mentioned _inits for Command. In particular line 665 and 2398
sh.py:665: DeprecationWarning: There is no current event loop asyncio.get_event_loop()
sh.py:2398: DeprecationWarning: There is no current event loop loop = asyncio.get_event_loop()
Depreciation note from asyncio
Note In Python versions 3.10.0–3.10.8 and 3.11.0 this function (and other functions which use it implicitly) emitted a [DeprecationWarning](https://docs.python.org/3/library/exceptions.html#DeprecationWarning) if there was no running event loop, even if the current loop was set on the policy. In Python versions 3.10.9, 3.11.1 and 3.12 they emit a [DeprecationWarning](https://docs.python.org/3/library/exceptions.html#DeprecationWarning) if there is no running event loop and no current loop is set. In some future Python release this will become an error
Am I using command incorrectly by not creating an asyncio event loop? Or is this just unintended depreciations? Any assistance would be great, trying to address this as it is showing up in my pytest code outputs, thank you!