Traceback (most recent call last): File…
- User
Traceback (most recent call last): File "C:\Users\AshotxXx\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\AshotxXx\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "C:\Users\AshotxXx\PycharmProjects\pythonProject1\main.py", line 83, in main await display_transactions(block_start, block_end) File "C:\Users\AshotxXx\PycharmProjects\pythonProject1\main.py", line 76, in display_transactions await asyncio.gather(*tasks) File "C:\Users\AshotxXx\PycharmProjects\pythonProject1\main.py", line 61, in process_block transactions = await get_external_transactions(block_number) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\AshotxXx\PycharmProjects\pythonProject1\main.py", line 20, in get_external_transactions async with semaphore: File "C:\Users\AshotxXx\AppData\Local\Programs\Python\Python311\Lib\asyncio\locks.py", line 15, in aenter await self.acquire() File "C:\Users\AshotxXx\AppData\Local\Programs\Python\Python311\Lib\asyncio\locks.py", line 387, in acquire await fut asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Users\AshotxXx\PycharmProjects\pythonProject1\main.py", line 90, in asyncio.run(main()) File "C:\Users\AshotxXx\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 190, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "C:\Users\AshotxXx\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 123, in run raise KeyboardInterrupt() KeyboardInterrupt
Process finished with exit code -1073741510 (0xC000013A: interrupted by Ctrl+C)
Fix it all
- Assistant
It seems that the script was interrupted by the KeyboardInterrupt exception, which is raised when the program is terminated using Ctrl+C. If you want to handle this exception gracefully and prevent it from showing the traceback, you can modify your code in the following way:
pythonimport asyncio async def main(): try: # your main code here await display_transactions(block_start, block_end) except asyncio.CancelledError: print("The process was cancelled")