Run Connect subscriptions and plugin event hooks without blocking the caller. On gevent uWSGI workers, dispatch runs in a spawned greenlet so slow webhooks, scripts, or plugin handlers cannot stall live-proxy teardown or streaming paths. Celery prefork workers (gevent patched but n
(
event_type, channel_id=None, channel_name=None, **details
)
| 789 | |
| 790 | |
| 791 | def _dispatch_system_event_integrations( |
| 792 | event_type, channel_id=None, channel_name=None, **details |
| 793 | ): |
| 794 | """ |
| 795 | Run Connect subscriptions and plugin event hooks without blocking the caller. |
| 796 | |
| 797 | On gevent uWSGI workers, dispatch runs in a spawned greenlet so slow webhooks, |
| 798 | scripts, or plugin handlers cannot stall live-proxy teardown or streaming paths. |
| 799 | Celery prefork workers (gevent patched but no hub) run synchronously instead. |
| 800 | """ |
| 801 | |
| 802 | def _run(): |
| 803 | try: |
| 804 | dispatch_event_system( |
| 805 | event_type, |
| 806 | channel_id=channel_id, |
| 807 | channel_name=channel_name, |
| 808 | **details, |
| 809 | ) |
| 810 | except Exception as e: |
| 811 | logger.error( |
| 812 | "Failed to dispatch Connect/plugin handlers for event %s: %s", |
| 813 | event_type, |
| 814 | e, |
| 815 | ) |
| 816 | |
| 817 | if _should_use_sync_websocket_send(): |
| 818 | _run() |
| 819 | elif _is_gevent_monkey_patched(): |
| 820 | import gevent |
| 821 | |
| 822 | gevent.spawn(_run) |
| 823 | else: |
| 824 | _run() |
| 825 | |
| 826 | |
| 827 | def log_system_event(event_type, channel_id=None, channel_name=None, **details): |