You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to use input/ainput for debugging purpose. So I start my python script in the console.
And to use input I currently start a thread which simply does input() in a while True loop and "exec()" the input I enter.
Then I can enter into the console something like "print(self.myvariable)" or other debbuging stuff.
Since I also use an asyncio loop in my script, I thought it might be more efficient to use an async input, instead of creating a thread for it. So I searched for it and found this aioconsole library. It seems to work to use ainput and aexec instead, but locals and globals are not accessable in aexec. I can do local=locals() for aexec, but how to also hand over globals() ?
Is aioconsole even the right module for this usecase?
Example code with none async that runs in a thread:
while True:
put_in = input("\n")
try:
exec(put_in)
except Exception as err:
print(err)
I can print any local or global variable from the script this way for debugging, or even set a variable to a new value.
The text was updated successfully, but these errors were encountered:
Hi,
I would like to use input/ainput for debugging purpose. So I start my python script in the console.
And to use input I currently start a thread which simply does input() in a while True loop and "exec()" the input I enter.
Then I can enter into the console something like "print(self.myvariable)" or other debbuging stuff.
Since I also use an asyncio loop in my script, I thought it might be more efficient to use an async input, instead of creating a thread for it. So I searched for it and found this aioconsole library. It seems to work to use ainput and aexec instead, but locals and globals are not accessable in aexec. I can do local=locals() for aexec, but how to also hand over globals() ?
Is aioconsole even the right module for this usecase?
Example code with none async that runs in a thread:
I can print any local or global variable from the script this way for debugging, or even set a variable to a new value.
The text was updated successfully, but these errors were encountered: