Skip to content

Commit

Permalink
@wip new sleep function
Browse files Browse the repository at this point in the history
  • Loading branch information
cian authored and cian committed Feb 25, 2023
1 parent d39e2e3 commit 7cc1272
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/assets/scriptor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def print(*args, **kwargs):
old_print(logging.format_text(*args, **kwargs))


from .utils import sleep

class prototypes:
list = ListModule
singleton = SingletonModule
Expand Down
10 changes: 10 additions & 0 deletions src/assets/scriptor/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,13 @@ def get_json_object(text: str):
except ValueError as e:
return False
return True

async def sleep(ms: int):
if is_pyodide_context():
import manager
await manager.sleep(ms)
else:
import asyncio
if ms > 0 or ms < 0:
ms = float(ms)/1000.0
await asyncio.sleep(ms)

0 comments on commit 7cc1272

Please sign in to comment.