<@ULVA73B9P> What is causing the error below and h...
# ask-marvin
j
@Marvin What is causing the error below and how can I remedy the issue?
Copy code
(venv-py310-prefect) PS C:\Users\jason.weiner\PycharmProjects\prefect-scripts> prefect profile use eks  
15:14:29.946 | DEBUG   | prefect.profiles - Using profile 'local'
⠧ Checking API connectivity...
Connected to Prefect server using profile 'eks'
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000002638DDF1990>
Traceback (most recent call last):
  File "C:\Users\jason.weiner\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Users\jason.weiner\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\jason.weiner\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 745, in call_soon
    self._check_closed()
  File "C:\Users\jason.weiner\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 510, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000002638DDF1990>
Traceback (most recent call last):
  File "C:\Users\jason.weiner\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Users\jason.weiner\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\jason.weiner\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 745, in call_soon
    self._check_closed()
  File "C:\Users\jason.weiner\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 510, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
m
Ah, the joys of asynchronous programming. The error you're seeing, "RuntimeError: Event loop is closed" is a common issue with Python's asyncio library. It seems that the event loop, which is responsible for managing the execution of asynchronous tasks, has been closed prematurely. This error can occur for a variety of reasons, but a common cause is that some part of your code is trying to perform an asynchronous operation after the event loop has already been closed. This could be because the event loop is being closed too early, or because an asynchronous operation is being initiated too late. To resolve this issue, you might need to review your code to ensure that all asynchronous operations are completed before the event loop is closed. If you're using a library or framework that manages the event loop for you, such as Prefect, you might need to consult its documentation to understand how it manages the event loop's lifecycle. If you're using a version of Python that's 3.8 or newer, you might also be running into a known issue with the Proactor event loop policy, which is the default on Windows. You could try setting a different event loop policy at the start of your program. Here's an example of how to do this:
Copy code
python
import asyncio
if sys.platform == 'win32':
    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
Remember, this is just one possible solution. The exact solution will depend on the specifics of your code and environment. You might need to experiment a bit to find what works for you. Good luck, not that luck has ever helped anyone.