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
This is a frustrating bug because I can't reproduce it in a minimal environment.
But in my application, if I load_dotenv() in a top-level I cannot modal X where X id deploy, run, serve. Note that I only experience this error with 3.12, never 3.11, and for a while I was modal deploying Python 3.12 apps from a local 3.11 interpreter.
Normally I wouldn't submit an issue for something I can't reproduce minimally and normally I wouldn't paste a long error log without doing more work but for me this is really opaque and it took me a while to even figure out that load_dotenv was causing the issue. I get these logs:
(venv3.12.5) ~/code/my_repository $ python -m modal serve --env etl my_app_folder/main.py
╭─ Error ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Non-thread-safe operation invoked on an event loop other than the current one │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Task was destroyed but it is pending!
source_traceback: Object created at (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/Users/zsiegel/code/my_repository/venv3.12.5/lib/python3.12/site-packages/modal/__main__.py", line 85, in <module>
main()
File "/Users/zsiegel/code/my_repository/venv3.12.5/lib/python3.12/site-packages/modal/__main__.py", line 24, in main
entrypoint_cli()
File "/Users/zsiegel/code/my_repository/venv3.12.5/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
return self.main(*args, **kwargs)
File "/Users/zsiegel/code/my_repository/venv3.12.5/lib/python3.12/site-packages/typer/core.py", line 728, in main
return _main(
File "/Users/zsiegel/code/my_repository/venv3.12.5/lib/python3.12/site-packages/typer/core.py", line 197, in _main
rv = self.invoke(ctx)
File "/Users/zsiegel/code/my_repository/venv3.12.5/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/zsiegel/code/my_repository/venv3.12.5/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/zsiegel/code/my_repository/venv3.12.5/lib/python3.12/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "/Users/zsiegel/code/my_repository/venv3.12.5/lib/python3.12/site-packages/typer/main.py", line 707, in wrapper
return callback(**use_params)
File "/Users/zsiegel/code/my_repository/venv3.12.5/lib/python3.12/site-packages/modal/cli/run.py", line 328, in serve
with serve_app(app, app_ref, environment_name=env):
File "/Users/zsiegel/code/my_repository/venv3.12.5/lib/python3.12/site-packages/synchronicity/synchronizer.py", line 593, in proxy_method
return wrapped_method(instance, *args, **kwargs)
File "/Users/zsiegel/code/my_repository/venv3.12.5/lib/python3.12/site-packages/synchronicity/combined_types.py", line 26, in __call__
return self._func(*args, **kwargs)
File "/Users/zsiegel/code/my_repository/venv3.12.5/lib/python3.12/site-packages/synchronicity/synchronizer.py", line 511, in f_wrapped
return self._run_function_sync(res, f)
File "/Users/zsiegel/code/my_repository/venv3.12.5/lib/python3.12/site-packages/synchronicity/synchronizer.py", line 312, in _run_function_sync
coro_task = asyncio.ensure_future(coro, loop=loop)
File "/Users/zsiegel/.pyenv/versions/3.12.5/lib/python3.12/asyncio/tasks.py", line 695, in ensure_future
return loop.create_task(coro_or_future)
File "/Users/zsiegel/.pyenv/versions/3.12.5/lib/python3.12/asyncio/base_events.py", line 458, in create_task
task = tasks.Task(coro, loop=self, name=name, context=context)
task: <Task pending name='Task-2' coro=<Synchronizer._wrap_check_async_leakage.<locals>.coro_wrapped() done, defined at /Users/zsiegel/code/my_repository/venv3.12.5/lib/python3.12/site-packages/synchronicity/synchronizer.py:225> created at /Users/zsiegel/.pyenv/versions/3.12.5/lib/python3.12/asyncio/base_events.py:458>
sys:1: RuntimeWarning: coroutine 'wrap_coro_exception.<locals>.coro_wrapped' was never awaited
sys:1: RuntimeWarning: coroutine '_AsyncGeneratorContextManager.__aenter__' was never awaited
If you have to close this because it's incomplete please go ahead, but if anyone knows what this error is and how to avoid it maybe you can:
document what not to do (I still don't know what rule I was violating)
improve the error message
The text was updated successfully, but these errors were encountered:
This is a frustrating bug because I can't reproduce it in a minimal environment.
But in my application, if I
load_dotenv()
in a top-level I cannotmodal X
whereX
iddeploy
,run
,serve
. Note that I only experience this error with 3.12, never 3.11, and for a while I wasmodal deploy
ing Python 3.12 apps from a local 3.11 interpreter.Normally I wouldn't submit an issue for something I can't reproduce minimally and normally I wouldn't paste a long error log without doing more work but for me this is really opaque and it took me a while to even figure out that
load_dotenv
was causing the issue. I get these logs:If you have to close this because it's incomplete please go ahead, but if anyone knows what this error is and how to avoid it maybe you can:
The text was updated successfully, but these errors were encountered: