-
-
Notifications
You must be signed in to change notification settings - Fork 23
Description
Describe the bug
Our app runs inside a Linux docker, but some of us are still developing on Windows. resource is not available on Windows, making it impossible to run any management commands (like python manage.py migrate) once scheduler gets imported.
To Reproduce
Steps to reproduce the behavior:
- Follow installation guide on Windows: https://django-tasks-scheduler.readthedocs.io/en/stable/installation/
- Run
python manage.py migrate
> poetry run python manage.py migrate
Traceback (most recent call last):
File "...\backend\manage.py", line 23, in <module>
main()
File "...\backend\manage.py", line 19, in main
execute_from_command_line(sys.argv)
File "C:\Users\Avasam\AppData\Local\pypoetry\Cache\virtualenvs\backend-W7xVypE5-py3.12\Lib\site-packages\django\core\management\__init__.py", line 442, in execute_from_command_line
utility.execute()
File "C:\Users\Avasam\AppData\Local\pypoetry\Cache\virtualenvs\backend-W7xVypE5-py3.12\Lib\site-packages\django\core\management\__init__.py", line 416, in execute
django.setup()
File "C:\Users\Avasam\AppData\Local\pypoetry\Cache\virtualenvs\backend-W7xVypE5-py3.12\Lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\Avasam\AppData\Local\pypoetry\Cache\virtualenvs\backend-W7xVypE5-py3.12\Lib\site-packages\django\apps\registry.py", line 124, in populate
app_config.ready()
File "C:\Users\Avasam\AppData\Local\pypoetry\Cache\virtualenvs\backend-W7xVypE5-py3.12\Lib\site-packages\django\contrib\admin\apps.py", line 27, in ready
self.module.autodiscover()
File "C:\Users\Avasam\AppData\Local\pypoetry\Cache\virtualenvs\backend-W7xVypE5-py3.12\Lib\site-packages\django\contrib\admin\__init__.py", line 52, in autodiscover
autodiscover_modules("admin", register_to=site)
File "C:\Users\Avasam\AppData\Local\pypoetry\Cache\virtualenvs\backend-W7xVypE5-py3.12\Lib\site-packages\django\utils\module_loading.py", line 58, in autodiscover_modules
import_module("%s.%s" % (app_config.name, module_to_search))
File "C:\Users\Avasam\AppData\Local\Programs\Python\Python312\Lib\importlib\__init__.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 995, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "C:\Users\Avasam\AppData\Local\pypoetry\Cache\virtualenvs\backend-W7xVypE5-py3.12\Lib\site-packages\scheduler\admin\__init__.py", line 1, in <module>
from .ephemeral_models import QueueAdmin, WorkerAdmin
File "C:\Users\Avasam\AppData\Local\pypoetry\Cache\virtualenvs\backend-W7xVypE5-py3.12\Lib\site-packages\scheduler\admin\ephemeral_models.py", line 3, in <module>
from scheduler import views
File "C:\Users\Avasam\AppData\Local\pypoetry\Cache\virtualenvs\backend-W7xVypE5-py3.12\Lib\site-packages\scheduler\views\__init__.py", line 16, in <module>
from .job_views import job_detail, job_action
File "C:\Users\Avasam\AppData\Local\pypoetry\Cache\virtualenvs\backend-W7xVypE5-py3.12\Lib\site-packages\scheduler\views\job_views.py", line 15, in <module>
from scheduler.worker.commands import send_command, StopJobCommand
File "C:\Users\Avasam\AppData\Local\pypoetry\Cache\virtualenvs\backend-W7xVypE5-py3.12\Lib\site-packages\scheduler\worker\__init__.py", line 8, in <module>
from .worker import Worker, create_worker
File "C:\Users\Avasam\AppData\Local\pypoetry\Cache\virtualenvs\backend-W7xVypE5-py3.12\Lib\site-packages\scheduler\worker\worker.py", line 16, in <module>
from resource import struct_rusage
ModuleNotFoundError: No module named 'resource'
Since from resource import struct_rusage is only used for type annotations in scheduler\worker\worker.py, it would benefit from making it a type-only import (if TYPE_CHECKING) and stringifying the return type of wait_for_job_execution_process.
Patching the package that way seems to have been sufficient.
Expected behavior
No errors when running management commands on Windows
Screenshots
(see log above)
Desktop (please complete the following information):
- OS: Windows
- python version: 3.12.6
- django version: 5.0.12
- requirements.txt? No,
pyproject.toml:
[project]
dependencies = [
"django ~=5.0.6",
"django-allauth[socialaccount] ~=0.62.1",
"django-anymail ~=10.3",
"django-cors-headers ~=4.3.1",
"django-environ ~=0.11.2",
"django-tasks-scheduler ~=4.0.4",
"django-widget-tweaks ~=1.5.0",
"djangorestframework ~=3.15.1",
"djangorestframework-camel-case ~=1.4.2",
"gunicorn[gevent] ~=22.0.0",
"pillow ~=10.4.0",
"psycogreen ~=1.0.2",
"psycopg2-binary ~=2.9.9",
"uvicorn[standard] ~=0.29.0",
"zygoat-django ~=1.0.1",
]