Leaving Your Sock(et)s Hanging
A command pattern that I’ve used in multiple projects is an event-loop sidecar. The sidecar runs on it’s own thread and
does asynchronous IO; thereby increasing the responsiveness of the system which could be doing IO/CPU bound work. The
application (running on the main thread) interfaces with the sidecar through a synchronous API.
There are multiple caveats to this pattern. With python’s GIL, the sidecar should strictly be doing I/O to ensure that
the pattern has the desired effects. If you have a CPU bound sidecar, you’ll end up with an architecture which performs
worse than a single threaded job.
Setting up such a sidecar takes some time to get used to, but is easier in python 3.7+:
Srijan R. Shetty