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
Using prompt-toolkit 3.0.41, every time I launch scrapy shell (Scrapy 2.11.0) with ipython 8.18.0 and Python 3.10.12, the following stacktrace is produced:
File ~/.local/lib/python3.10/site-packages/scrapy/utils/console.py:108, in start_python_console(namespace, banner, shells)
106 shell = get_shell_embed_func(shells)
107 if shell is not None:
--> 108 shell(namespace=namespace, banner=banner)
109 except SystemExit: # raised when using exit() in python code.interact
110 pass
File /usr/lib/python3.10/site-packages/IPython/terminal/embed.py:251, in InteractiveShellEmbed.call(self, header, local_ns, module, dummy, stack_depth, compile_flags, **kw)
247 self.show_banner()
249 # Call the embedding code with a stack depth of 1 so it can skip over
250 # our call and get the original caller's namespaces.
--> 251 self.mainloop(
252 local_ns, module, stack_depth=stack_depth, compile_flags=compile_flags
253 )
255 self.banner2 = self.old_banner2
257 if self.exit_msg is not None:
File /usr/lib/python3.10/site-packages/IPython/terminal/embed.py:343, in InteractiveShellEmbed.mainloop(self, local_ns, module, stack_depth, compile_flags)
340 self.set_completer_frame()
342 with self.builtin_trap, self.display_trap:
--> 343 self.interact()
345 # now, purge out the local namespace of IPython's hidden variables.
346 if local_ns is not None:
File /usr/lib/python3.10/site-packages/IPython/terminal/interactiveshell.py:872, in TerminalInteractiveShell.interact(self)
869 print(self.separate_in, end='')
871 try:
--> 872 code = self.prompt_for_code()
873 except EOFError:
874 if (not self.confirm_exit)
875 or self.ask_yes_no('Do you really want to exit ([y]/n)?','y','n'):
File /usr/lib/python3.10/site-packages/IPython/terminal/interactiveshell.py:813, in TerminalInteractiveShell.prompt_for_code(self)
807 text = asyncio_loop.run_until_complete(
808 self.pt_app.prompt_async(
809 default=default, **self._extra_prompt_options()
810 )
811 )
812 else:
--> 813 text = self.pt_app.prompt(
814 default=default,
815 inputhook=self._inputhook,
816 **self._extra_prompt_options(),
817 )
819 return text
File ~/.local/lib/python3.10/site-packages/prompt_toolkit/application/application.py:994, in Application.run(self, pre_run, set_exception_handler, handle_sigint, in_thread, inputhook)
991 return asyncio.run(coro)
992 else:
993 # Use existing loop.
--> 994 return loop.run_until_complete(coro)
996 else:
997 # No loop installed. Run like usual.
998 return asyncio.run(coro)
File /usr/lib64/python3.10/asyncio/base_events.py:625, in BaseEventLoop.run_until_complete(self, future)
614 """Run until the Future is done.
615
616 If the argument is a coroutine, it is wrapped in a Task.
(...)
622 Return the Future's result, or raise its exception.
623 """
624 self._check_closed()
--> 625 self._check_running()
627 new_task = not futures.isfuture(future)
628 future = tasks.ensure_future(future, loop=self)
File /usr/lib64/python3.10/asyncio/base_events.py:584, in BaseEventLoop._check_running(self)
582 def _check_running(self):
583 if self.is_running():
--> 584 raise RuntimeError('This event loop is already running')
585 if events._get_running_loop() is not None:
586 raise RuntimeError(
587 'Cannot run the event loop while another loop is running')
RuntimeError: This event loop is already running
The cause seems to be using asyncio.get_event_loop(), which will soon be deprecated. This is related to scrapy/scrapy#6160.
The text was updated successfully, but these errors were encountered:
Very annoying indeed. It's polluting my xonsh sessions on python 3.12.3 (and prompt toolkit 3.0.36).
Until a suitable solution is found:
# to be added at the top of the definition of the prompt-toolkit shell# in: xonsh.ptk_shell.shellimportwarningswarnings.filterwarnings("ignore", category=DeprecationWarning, module="prompt_toolkit.eventloop.utils", lineno=118)
To silence:
.../lib/python3.12/site-packages/prompt_toolkit/eventloop/utils.py:118: DeprecationWarning: There is no current event loop
return asyncio.get_event_loop_policy().get_event_loop()
This won't fix op's runtime error but it will keep your shell clean if you'r using xonsh/0.16.0.
EDIT: updating to version 3.0.43 (>3.0.36) of the toolkit should fix it from my understanding of the code and this review on op's PR
Using prompt-toolkit 3.0.41, every time I launch scrapy shell (Scrapy 2.11.0) with ipython 8.18.0 and Python 3.10.12, the following stacktrace is produced:
The cause seems to be using
asyncio.get_event_loop()
, which will soon be deprecated. This is related to scrapy/scrapy#6160.The text was updated successfully, but these errors were encountered: