Things to check first
AnyIO version
4.11
Python version
3.11
What happened?
I have a package with an entry point defined in pyproject.toml and I want to run a function in a worker process. The function imports dill, which raises
[snip]
File "/data/ilia/envs/famo/lib/python3.11/site-packages/dill/_dill.py", line 80, in <module>
import __main__ as _main_module
^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named '__main__'
I've tried to debug this a bit, and it turns out that importlib.util.spec_from_file_location (used in the worker process to set up __main__) always returns None if the path does not end in .py or .pyc.
sys.modules["__main__"].__spec__ is also None in that case.
How can we reproduce the bug?
Write a small dummy package with an entry point defined in pyproject.toml that runs a function in a worker process.