Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/textual/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
9 changes: 7 additions & 2 deletions src/textual/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

from __future__ import annotations

import sys
import asyncio
import enum
import inspect
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")

Expand Down