-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Stubgen fails with timeout for locust #9103
Comments
This looks like an issue with $ python -c "from mypy.moduleinspect import ModuleInspect; m = ModuleInspect(); m.get_package_properties('locust')"
File "<string>", line 1, in <module>
File "/Users/hoefling/projects/private/locust/.direnv/python-3.8.5/lib/python3.8/site-packages/mypy/moduleinspect.py", line 137, in get_package_properties
res = self._get_from_queue()
File "/Users/hoefling/projects/private/locust/.direnv/python-3.8.5/lib/python3.8/site-packages/mypy/moduleinspect.py", line 163, in _get_from_queue
raise RuntimeError('Timeout waiting for subprocess')
RuntimeError: Timeout waiting for subprocess Workaround for $ python -c "import locust; print(locust.__path__[0])" | xargs stubgen
Processed 50 modules
Generated files under out/locust/ |
Same with PyInstaller.
|
I think there are 2 separate issue here. Locust issue (caused by gevent+multiprocessing)
# threading.Thread.start():
...
self._started.wait() This thread is an internal Possible Solutions/Workarounds:
monkey.patch_all() Not sure if PyInstaller issue (caused by looong imports)It simply appears that some of the modules in @Avasam To get a better idea which module caused it add import importlib
importlib.import_module(<module name>)
# i.e.
importlib.import_module('PyInstaller.hooks.hook-django') Next release of mypy (0.980) should have the increased timeout. You can give it a try by installing the last built development wheels of the pip install --upgrade --find-links https://github.com/mypyc/mypy_mypyc-wheels/releases/latest mypy |
@ben9923 Thanks for the explanation. PyInstaller still fails on:
(even if I fix that error it still finishes in that amount of time) Could stubgen just skip failing imports with a warning instead of blocking everything and/or does |
I think it does warn on import errors and proceeds with stub generation. IIRC I got that error too (after less than 30s) and it kept going. 66s is a lot, not sure if increasing the timeout to more than the 0.980 30s would be cool for UX in case of forever-hanging imports. Just because it's so much time - you could further trace the imports in that Django module, to find a more specific cause for it taking so long. |
Definitely not. It's not part of their public API, and 66s is a lot. In any case, it's not blocking me from doing the work I wanted, as I just ended up using Pyright's stub generation instead (a bit less complete, but I manually filled in the rest). So I mainly wanted to raise this as a potential issue (if it happened for this lib, it could happen for other).
I tried on a different machine and it went much faster. I'm fairly certain it depends on how many packages you got installed. As it tries to scan the entirety of |
Another solution could be adding a CLI flag (or an env var to minimize code changes?) for |
I'll note that this performance issue shouldn't be a problem anymore with PyInstaller anyway thanks to pyinstaller/pyinstaller#7943 But the OP about locust still stand |
Hi,
I'm trying to generate type stubs for Locust and stubgen fails with a timeout (see details below).
I was wondering if someone has any insight into what causes this or how to fix it.
Please provide more information to help us understand the issue:
Are you reporting a bug, or opening a feature request?
Bug
Please insert below the code you are checking with mypy,
or a mock-up repro if the source is private. We would appreciate
if you try to simplify your case to a minimal repro.
What is the actual behavior/output?
What is the behavior/output you expect?
No console output and generated stubs in
out/
.What are the versions of mypy and Python you are using?
Do you see the same issue after installing mypy from Git master?
Yes:
The text was updated successfully, but these errors were encountered: