You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to run the application for monitoring Fastapi debug server. I want to catch stdout output from several debug servers.
But catch an error because method render is not async.
Catch error because method render does not async.
Could be helped to find the example of an idea of how to do it with textual?
import asyncio
from asyncio.subprocess import PIPE
import logging
from rich.logging import RichHandler
from textual.app import App
from textual.widget import Widget
from textual.widgets import Header
from rich.panel import Panel
FORMAT = "%(message)s"
logging.basicConfig(
level="NOTSET", format=FORMAT, datefmt="[%X]", handlers=[RichHandler()]
)
log = logging.getLogger("rich")
class ServerLogs(Widget):
async def on_mount(self):
self.set_interval(1, self.refresh)
self.process = await asyncio.create_subprocess_shell("uvicorn server:app --reload", stdout=PIPE, stderr=PIPE)
def render(self):
line_log = self.process.stdout.readline()
return Panel("sss")
class MonitorApp(App):
async def on_mount(self):
await self.view.dock(Header())
await self.view.dock(ServerLogs())
MonitorApp.run()
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I tried to run the application for monitoring Fastapi debug server. I want to catch stdout output from several debug servers.
But catch an error because method render is not async.
Catch error because method render does not async.
Could be helped to find the example of an idea of how to do it with textual?
Beta Was this translation helpful? Give feedback.
All reactions