
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
fastapi-event is event dispatcher for FastAPI framework.
pip3 install fastapi-event
from fastapi_event import BaseEvent
class TestEvent(BaseEvent):
async def run(self, parameter=None):
...
Inherit BaseEvent
and override run()
method.
from fastapi_event import BaseEvent
class FirstEvent(BaseEvent):
ORDER = 1 # HERE(Optional)
async def run(self, parameter=None):
...
class SecondEvent(BaseEvent):
ORDER = 2 # HERE(Optional)
async def run(self, parameter=None):
...
If you want to determine the order between events, specify ORDER
in your event.
Then, regardless of the order in which the events are stored, they will be executed in the order specified in ORDER
variable.
However, ORDER
does not work when run_at_once=True
.
from pydantic import BaseModel
class TestEventParameter(BaseModel):
id: str
pw: str
In case of need parameter, you have to inherit BaseModel
and set fields.
from fastapi import FastAPI
from fastapi_event import EventHandlerMiddleware
app = FastAPI()
app.add_middleware(EventHandlerMiddleware)
from fastapi_event import EventListener
@EventListener()
async def test():
...
Set @EventListener()
decorator on the function that emits the event.
@EventListener(run_at_once=False)
If you pass run_at_once=False
, it will execute in the order in which store()
is called. (or according to the ORDER
variable defined in the event)
Otherwise, it will execute through asyncio.gather()
to run at once.
from fastapi_event import EventListener, event_handler
@EventListener()
async def test():
await event_handler.store(
event=TestEvent,
parameter=TestParameter(id="hide", pw="hide"), # Optional
)
Store your event to handler via store()
method. (parameter is optional)
An event will be emitted after the function has finished executing.
FAQs
Event dispatcher for FastAPI
We found that fastapi-event demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.