https://prefect.io logo
Title
c

Cody

04/13/2023, 7:41 PM
Hello, not sure if this is the place to ask. If I should put questions in another place please let me know. I have been following the deployments tutorial at https://docs.prefect.io/latest/tutorials/deployments/#run-a-prefect-server When I try to run the
prefect profile use 'local'
command I get the error below, but the profile is still changed. I'm not sure if the error is going to cause issues down the road.
## Running on powershell in Windows 11

##
## View Current profile
##
❯❯❯  prefect profile ls
┏━━━━━━━━━━━━━━━━━━━━━┓
┃ Available Profiles: ┃
┡━━━━━━━━━━━━━━━━━━━━━┩
│             default │
│             * local │
└─────────────────────┘
   * active profile
##
## Change to 'default'. Error gets thrown
##

❯❯❯  prefect profile use 'default'
⠸ Checking API connectivity...
Connected to Prefect Cloud using profile 'default'
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000002A9D9185310>
Traceback (most recent call last):
  File "C:\Users\Cody\anaconda3\envs\prefect2\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Users\Cody\anaconda3\envs\prefect2\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\Cody\anaconda3\envs\prefect2\lib\asyncio\base_events.py", line 719, in call_soon
    self._check_closed()
  File "C:\Users\Cody\anaconda3\envs\prefect2\lib\asyncio\base_events.py", line 508, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

##
## See that profile has changed
##

❯❯❯  prefect profile ls
┏━━━━━━━━━━━━━━━━━━━━━┓
┃ Available Profiles: ┃
┡━━━━━━━━━━━━━━━━━━━━━┩
│           * default │
│               local │
└─────────────────────┘
   * active profile

##
## Change back to 'local'. Error is thrown again.
##

❯❯❯  prefect profile use 'local'
⠋ Checking API connectivity...
Connected to Prefect server using profile 'local'
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000001F385726310>
Traceback (most recent call last):
  File "C:\Users\Cody\anaconda3\envs\prefect2\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Users\Cody\anaconda3\envs\prefect2\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\Cody\anaconda3\envs\prefect2\lib\asyncio\base_events.py", line 719, in call_soon
    self._check_closed()
  File "C:\Users\Cody\anaconda3\envs\prefect2\lib\asyncio\base_events.py", line 508, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000001F385726310>
Traceback (most recent call last):
  File "C:\Users\Cody\anaconda3\envs\prefect2\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Users\Cody\anaconda3\envs\prefect2\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\Cody\anaconda3\envs\prefect2\lib\asyncio\base_events.py", line 719, in call_soon
    self._check_closed()
  File "C:\Users\Cody\anaconda3\envs\prefect2\lib\asyncio\base_events.py", line 508, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

##
## Show that profile was switched
##

❯❯❯  prefect profile ls
┏━━━━━━━━━━━━━━━━━━━━━┓
┃ Available Profiles: ┃
┡━━━━━━━━━━━━━━━━━━━━━┩
│             default │
│             * local │
└─────────────────────┘
   * active profile
1
r

Ryan Peden

04/15/2023, 12:53 AM
I believe this is caused by a bug in the Python stdlib that occurs on Windows in Python 3.8.0 to 3.10.5. Running Python 3.10.6+ or 3.11 should solve the problem. I'm running Windows 11 as well, and after a quick test I get this error in Python 3.9.7 but not in Python 3.10.6. If you can't update to a newer version of Python, I wouldn't worry much about the error. It happens after Prefect's code has finished running and Python is trying to shut down, so Prefect has already done everything needed to switch your profile.
c

Cody

04/17/2023, 6:00 PM
Thats good to know. Thank you!