
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Documentation: https://engin.readthedocs.io/
Source Code: https://github.com/invokermain/engin
Engin is a lightweight application framework powered by dependency injection, it helps you build and maintain large monoliths and many microservices.
The Engin framework gives you:
Engin is available on PyPI, install it using your favourite dependency manager:
pip install engin
poetry add engin
uv add engin
A small example which shows some of the features of Engin. This application makes 3 http requests and shuts itself down.
import asyncio
from httpx import AsyncClient
from engin import Engin, Invoke, Lifecycle, OnException, Provide, Supervisor
def httpx_client_factory(lifecycle: Lifecycle) -> AsyncClient:
# create our http client
client = AsyncClient()
# this will open and close the AsyncClient as part of the application's lifecycle
lifecycle.append(client)
return client
async def main(
httpx_client: AsyncClient,
supervisor: Supervisor,
) -> None:
async def http_requests_task():
# simulate a background task
for x in range(3):
await httpx_client.get("https://httpbin.org/get")
await asyncio.sleep(1.0)
# raise an error to shutdown the application, normally you wouldn't do this!
raise RuntimeError("Forcing shutdown")
# supervise the http requests as part of the application's lifecycle
supervisor.supervise(http_requests_task, on_exception=OnException.SHUTDOWN)
# define our modular application
engin = Engin(Provide(httpx_client_factory), Invoke(main))
# run it!
asyncio.run(engin.run())
With logs enabled this will output:
INFO:engin:starting engin
INFO:engin:startup complete
INFO:httpx:HTTP Request: GET https://httpbin.org/get "HTTP/1.1 200 OK"
INFO:httpx:HTTP Request: GET https://httpbin.org/get "HTTP/1.1 200 OK"
INFO:httpx:HTTP Request: GET https://httpbin.org/get "HTTP/1.1 200 OK"
ERROR:engin:supervisor task 'http_requests_task' raised RuntimeError, starting shutdown
Traceback (most recent call last):
File "C:\dev\python\engin\src\engin\_supervisor.py", line 58, in __call__
await self.factory()
File "C:\dev\python\engin\readme_example.py", line 29, in http_requests_task
raise RuntimeError("Forcing shutdown")
RuntimeError: Forcing shutdown
INFO:engin:stopping engin
INFO:engin:shutdown complete
Engin is heavily inspired by Uber's Fx framework for Go and the Injector framework for Python.
They are both great projects, go check them out.
FAQs
An async-first modular application framework
We found that engin 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.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.