Skip to content
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

[BUG] Does not import on Windows #144

Open
FaustinCarter opened this issue Dec 17, 2020 · 4 comments · May be fixed by #272
Open

[BUG] Does not import on Windows #144

FaustinCarter opened this issue Dec 17, 2020 · 4 comments · May be fixed by #272
Labels
bug Something isn't working

Comments

@FaustinCarter
Copy link

Describe the bug
Fails completely on Windows because resource is not available on Windows.

\lib\site-packages\fastapi_utils\timing.py", line 10, in <module> import resource
ModuleNotFoundError: No module named 'resource'

To Reproduce
Steps to reproduce the behavior:

  1. pip install fastapi-utils
    2.from fastapi_utils.timing import add_timing_middleware

Expected behavior
The import works.

Environment:

  • OS: Windows 10
  • Python version: 3.7

Additional context
https://stackoverflow.com/questions/37710848/importerror-no-module-named-resource

@FaustinCarter FaustinCarter added the bug Something isn't working label Dec 17, 2020
@FaustinCarter FaustinCarter changed the title [BUG] [BUG] Does not import on Windows Dec 17, 2020
@wasdee
Copy link

wasdee commented Jan 9, 2021

work around is to run the fastapi app in docker.

don't know what is the equivalent package on windows side.

@uncovor
Copy link

uncovor commented Oct 29, 2021

Any update in this bug?

@menaitm
Copy link

menaitm commented Jun 15, 2022

any update?

@rabigabor
Copy link

In the timing.py, you can use this code snippet instead, it gives you almost the same result:

def _get_cpu_time() -> float:
    """
    Generates the cpu time to report. Adds the user and system time, following the implementation from timing-asgi
    """
    return time.process_time()

(Python 3.3+ needed)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants