diff --git a/src/sage/misc/timing.py b/src/sage/misc/timing.py index 7e13c533e4d..c9e9bf747f9 100644 --- a/src/sage/misc/timing.py +++ b/src/sage/misc/timing.py @@ -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: