-
-
Notifications
You must be signed in to change notification settings - Fork 525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I get This event loop is already running
when combining adlfs
and --autoreload
#6934
Comments
I've tried adding import nest_asyncio
nest_asyncio.apply() to the top of the script I'm serving. Then I get 2024-06-24 12:25:17,809 Exception in callback BaseAsyncIOLoop._handle_events(4, 1)
handle: <Handle BaseAsyncIOLoop._handle_events(4, 1)>
Traceback (most recent call last):
File "/opt/conda/lib/python3.11/asyncio/events.py", line 80, in _run
self._context.run(self._callback, *self._args)
RuntimeError: cannot enter context: <_contextvars.Context object at 0x7f2c558fb240> is already entered
2024-06-24 12:25:18,165 WebSocket connection opened
2024-06-24 12:25:18,166 ServerConnection created |
when combining
adlfs and
--autoreload`This event loop is already running
when combining adlfs
and --autoreload
I've added a minimum, reproducible example in the top post |
You can work around the problem by not using the adfls filesystem the first time the script is executed with autoreload. I've added the minimum, reproducible example above. |
This event loop is already running
when combining adlfs
and --autoreload
This event loop is already running
when combining adlfs
and --autoreload
In general Below is the pyinstrument profiling where I do a Executing the same function with the same arguments with |
It's likely not acquiring the lock that takes so long but the actual computation. Looking at threaded applications with a profiler is notoriously difficult and the profiler itself may significantly distort the results. |
If creating a
filesystem
usingfrom adlfs import AzureBlobFileSystem
. I use thatfilesystem
to dopd.read_parquet(... filesystem=filesystem)
anddf.to_parquet(..., filesystem=filesystem)
.When I serve my app with
--autoreload
I getI believe the line
self._loop.asyncio_loop.run_until_complete(stop_autoreload())
above needs to be able to handle if the loop is already running. It is already running because with autoreload the script is run one time before the server actually starts. And this runs theadlfs
async functionality.Minimum, reproducible example
panel==1.4.4, adfls=2024.4.1
test
export AZURE_CONNECTIONSTRING_TEST="DefaultEndpointsProtocol=https;AccountName=.."
python app.py
to create the datapanel serve app.py --autoreload --index app
The interesting thing is that if you raise an exception
raise ValueError()
the application will serve and show you the error. When you remove theValueError
the application will reload and work fine. I.e. the problem is that something else gets a chance to start the ioloop before Panel with autoreload.Work Around
You can work around the problem if you make sure not to use the adfls filesystem the first time the script is executed.
Additional Context
The text was updated successfully, but these errors were encountered: