Skip to content

Commit

Permalink
src/sage/misc/timing.py (cputime): If module 'resource' is not availa…
Browse files Browse the repository at this point in the history
…ble, fall back to walltime
  • Loading branch information
mkoeppe committed Nov 5, 2024
1 parent ec91df5 commit 224faea
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/sage/misc/timing.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,16 @@ def cputime(t=0, subprocesses=False):
CPU time is reported correctly because subprocesses can be
started and terminated at any given time.
"""
try:
import resource
except ImportError:
# The module 'resource' is removed in Pyodide to browser limitations.
return walltime(t)

if isinstance(t, GlobalCputime):
subprocesses = True

if not subprocesses:
import resource
try:
t = float(t)
except TypeError:
Expand Down

0 comments on commit 224faea

Please sign in to comment.