Add changed files to reload trigger listener
This commit is contained in:
parent
16256522f6
commit
f3035abfae
|
@ -3,7 +3,6 @@ from __future__ import annotations
|
|||
from inspect import isawaitable
|
||||
from typing import TYPE_CHECKING, Any, Callable, Iterable, Optional
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sanic import Sanic
|
||||
|
||||
|
@ -12,6 +11,7 @@ def trigger_events(
|
|||
events: Optional[Iterable[Callable[..., Any]]],
|
||||
loop,
|
||||
app: Optional[Sanic] = None,
|
||||
**kwargs,
|
||||
):
|
||||
"""
|
||||
Trigger event callbacks (functions or async)
|
||||
|
@ -22,8 +22,12 @@ def trigger_events(
|
|||
if events:
|
||||
for event in events:
|
||||
try:
|
||||
result = event() if not app else event(app)
|
||||
result = event(**kwargs) if not app else event(app, **kwargs)
|
||||
except TypeError:
|
||||
result = event(loop) if not app else event(app, loop)
|
||||
result = (
|
||||
event(loop, **kwargs)
|
||||
if not app
|
||||
else event(app, loop, **kwargs)
|
||||
)
|
||||
if isawaitable(result):
|
||||
loop.run_until_complete(result)
|
||||
|
|
|
@ -2,7 +2,6 @@ from __future__ import annotations
|
|||
|
||||
import os
|
||||
import sys
|
||||
|
||||
from asyncio import new_event_loop
|
||||
from itertools import chain
|
||||
from multiprocessing.connection import Connection
|
||||
|
@ -64,7 +63,7 @@ class Reloader:
|
|||
trigger_events(before_trigger, loop, app)
|
||||
self.reload(",".join(changed) if changed else "unknown")
|
||||
if after_trigger:
|
||||
trigger_events(after_trigger, loop, app)
|
||||
trigger_events(after_trigger, loop, app, changed=changed)
|
||||
sleep(self.interval)
|
||||
else:
|
||||
if reloader_stop:
|
||||
|
|
Loading…
Reference in New Issue
Block a user