Skip to content

[BUG] Does not import on Windows #144

Open

Description

@FaustinCarter

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

Activity

  1. changed the title [-][BUG][/-] [+][BUG] Does not import on Windows[/+] on Dec 17, 2020
  2. ninyawee commented on Jan 9, 2021

    @ninyawee

    work around is to run the fastapi app in docker.

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

  3. uncovor commented on Oct 29, 2021

    @uncovor

    Any update in this bug?

  4. menaitm commented on Jun 15, 2022

    @menaitm

    any update?

  5. rabigabor commented on Sep 2, 2022

    @rabigabor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions