33"""
44
55# built-in
6+ from argparse import Namespace
7+ import asyncio
68from logging import getLogger as _getLogger
9+ from typing import Optional
710
811# third-party
912from vcorelib .io import MarkdownMixin
1013from vcorelib .io .types import JsonObject as _JsonObject
1114
1215# internal
1316from runtimepy import PKG_NAME
17+ from runtimepy .channel .environment .command import FieldOrChannel
1418from runtimepy .channel .environment .command .processor import (
1519 ChannelCommandProcessor ,
1620)
21+ from runtimepy .mixins .async_command import AsyncCommandProcessingMixin
1722from runtimepy .mixins .environment import ChannelEnvironmentMixin
1823from runtimepy .mixins .logging import LoggerMixinLevelControl
1924
2025
2126class RuntimeStructBase (
22- LoggerMixinLevelControl , ChannelEnvironmentMixin , MarkdownMixin
27+ LoggerMixinLevelControl ,
28+ ChannelEnvironmentMixin ,
29+ AsyncCommandProcessingMixin ,
30+ MarkdownMixin ,
2331):
2432 """A base runtime structure."""
2533
@@ -42,6 +50,23 @@ def __init__(
4250 self .command = ChannelCommandProcessor (self .env , self .logger )
4351 self .config = config
4452
53+ async def poll (args : Namespace , __ : Optional [FieldOrChannel ]) -> None :
54+ """Handle a test command."""
55+
56+ count = 1
57+ delay = 0.0
58+
59+ if args .extra :
60+ count = int (args .extra [0 ])
61+ if len (args .extra ) > 1 :
62+ delay = float (args .extra [1 ])
63+
64+ for _ in range (count ):
65+ self .poll ()
66+ await asyncio .sleep (delay )
67+
68+ self ._setup_async_commands (poll )
69+
4570 def poll (self ) -> None :
4671 """
4772 A method that other runtime entities can call to perform canonical
0 commit comments