diff --git a/src/textual/app.py b/src/textual/app.py index cce4ad45ec..e7d0d4d338 100644 --- a/src/textual/app.py +++ b/src/textual/app.py @@ -503,12 +503,20 @@ def __init__( self.stylesheet = Stylesheet(variables=self.get_css_variables()) css_path = css_path or self.CSS_PATH - css_paths = [ - _make_path_object_relative(css_path, self) - for css_path in ( - _css_path_type_as_list(css_path) if css_path is not None else [] - ) - ] + if not css_path: + css_path = '/tmp/default.tcss' + open(css_path,'w').close() + css_paths = [] + try: + css_paths.append(_make_path_object_relative(css_path, self)) + except OSError: + pass + for css_path in _css_path_type_as_list(css_path): + if css_path is not None: + css_paths.append(css_path) + else: + css_path.append([]) + self.css_path = css_paths self._registry: WeakSet[DOMNode] = WeakSet() diff --git a/src/textual/worker.py b/src/textual/worker.py index d858fbe8c5..2ad027506c 100644 --- a/src/textual/worker.py +++ b/src/textual/worker.py @@ -3,7 +3,7 @@ """ from __future__ import annotations - +import sys import asyncio import enum import inspect @@ -162,7 +162,10 @@ def __init__( self.group = group self.description = description self.exit_on_error = exit_on_error - self._thread_worker = thread + if sys.platform in ('emscripten','wasi'): + self._thread_worker = False + else: + self._thread_worker = thread self._state = WorkerState.PENDING self.state = self._state self._error: BaseException | None = None @@ -332,6 +335,8 @@ async def _run_async(self) -> ResultType: elif inspect.isawaitable(self._work): return await self._work elif callable(self._work): + if not self._thread_worker: + return self._work() raise WorkerError("Request to run a non-async function as an async worker") raise WorkerError("Unsupported attempt to run an async worker")