28 lines
821 B
Python
28 lines
821 B
Python
from typing import Union
|
|
|
|
import time
|
|
|
|
from phasmplatform.common.methodcall import MethodCall, MethodCallError
|
|
from phasmplatform.common.value import Value, NoneValue
|
|
|
|
from .base import BaseRunner
|
|
|
|
|
|
class PreludeRunner(BaseRunner):
|
|
__slots__ = ()
|
|
|
|
def do_call(self, call: MethodCall) -> Union[Value, MethodCallError]:
|
|
if call.method.name == 'on_module_loaded':
|
|
self.container_log[0]('PreludeRunner loaded')
|
|
return NoneValue
|
|
|
|
if call.method.name == 'sleep':
|
|
# This will block this thread
|
|
# Which is has to do until we can get the async really working
|
|
seconds = call.args[0].data
|
|
assert isinstance(seconds, int) # type hint
|
|
time.sleep(seconds)
|
|
return NoneValue
|
|
|
|
raise NotImplementedError(call)
|