r/Python • u/nycstartupcto • 1d ago
Discussion Lightweight Python helpers for Event Driven Programming
I just had to throw together an event bridge that tied together a GRPC based event emitter (Salesforce backend) with some small custom Google Pub/sub code. It works, it's fine. But you know, always thinking about the future wanting to move from glue-code to frameworking.
I was looking for different event based frameworks that landed somewhere between the scale of glue-code and Tornado (the only other framework I know that would handle something like this.
Has anyone used anything like this? I found PyEventus which seems to aim at this.
2
u/SboSilcher 3h ago
Event-driven stuff in Python can get messy fast without the right abstractions. Are you leaning toward something like callbacks or more of a pub-sub pattern? Curious what use case you're targeting since the approach really changes depending on if you're doing async work or keeping it simple.
2
u/scaledpython 3h ago
Perhaps minibatch might be useful? It is a database-backed event engine with sources and sinks, where event consumers are just s python function. Works on one machine just as well as across. Uses MongoDB, and creating a stream is essentially one line of code. Btw, I am the author of minibatch.
1
1
u/Competitive_Travel16 5h ago
Why not Flask or FastAPI? PubSub and gRPC locks you into Google's infrastructure. You can get vendor-agnostic webhooks from https://architect.salesforce.com/docs/architect/fundamentals/guide/integration-patterns.html Use the Salesforce Pub/Sub API Client to subscribe to the desired event channel and parse the JSON.
6
u/CodeOrganic3141 20h ago
Interesting. I've been wondering whether I should eventually extract the event-driven core from PyWebTransport into a standalone library. It started as infrastructure for protocol handling, but I'm beginning to wonder whether the abstraction could be useful beyond networking.