Fix: import main in _actor_id() causes app.run() hang — use module-level var instead
This commit is contained in:
@@ -17,6 +17,7 @@ from tools.scheduler import schedule_reminder, list_reminders, cancel_reminder
|
|||||||
import tools.scheduler as _scheduler_module
|
import tools.scheduler as _scheduler_module
|
||||||
from tools.home_assistant import home_assistant, set_ha_config
|
from tools.home_assistant import home_assistant, set_ha_config
|
||||||
from tools.google_workspace import list_calendars, get_calendar_events, list_gmail_messages, get_gmail_message
|
from tools.google_workspace import list_calendars, get_calendar_events, list_gmail_messages, get_gmail_message
|
||||||
|
import tools.google_workspace as _gws
|
||||||
import httpx
|
import httpx
|
||||||
import botocore.auth
|
import botocore.auth
|
||||||
import botocore.awsrequest
|
import botocore.awsrequest
|
||||||
@@ -190,6 +191,10 @@ async def main(payload: dict, context):
|
|||||||
adapter_config = payload.get('channel_adapter', {})
|
adapter_config = payload.get('channel_adapter', {})
|
||||||
channel_type = adapter_config.get('type', 'telegram')
|
channel_type = adapter_config.get('type', 'telegram')
|
||||||
|
|
||||||
|
actor_id_early = payload.get('actor_id', adapter_config.get('target_id', 'default'))
|
||||||
|
_current_actor_id = actor_id_early
|
||||||
|
_gws._current_actor_id = actor_id_early # sync to google_workspace module
|
||||||
|
|
||||||
if channel_type == 'telegram':
|
if channel_type == 'telegram':
|
||||||
adapter = TelegramAdapter(
|
adapter = TelegramAdapter(
|
||||||
chat_id=adapter_config.get('target_id', ''),
|
chat_id=adapter_config.get('target_id', ''),
|
||||||
|
|||||||
@@ -48,8 +48,13 @@ def _get_creds(actor_id: str) -> Credentials:
|
|||||||
|
|
||||||
|
|
||||||
def _actor_id():
|
def _actor_id():
|
||||||
import main as _main
|
# Read from module-level var set by main.py per invocation
|
||||||
return _main._current_actor_id
|
# DO NOT use 'import main as _main' — it re-runs main.py including app.run() which hangs
|
||||||
|
return _current_actor_id
|
||||||
|
|
||||||
|
|
||||||
|
# Set per-invocation by main.py before any tool call
|
||||||
|
_current_actor_id: str = ''
|
||||||
|
|
||||||
|
|
||||||
def _svc(api: str, version: str, creds: Credentials):
|
def _svc(api: str, version: str, creds: Credentials):
|
||||||
|
|||||||
Reference in New Issue
Block a user