Changed the structure of PollingMessengerInterface class. Now requests are put in a queue, then done by 'workers', so that requests from several context_id's can be processed asynchronously. And a few other reasons that are explained in the Triggers PR, I think.
Added graceful termination in MessengerInterface. When SIGINT is received, instead of abruptly terminating, shutdown() from MessengerInterface is called, gracefully shutting down the program. All requests received prior to that are processed normally, then the program shuts down.
Made an async wrapper in MessengerInterface base class, so that connect() is run as an async task, not blocking the code.
Checklist
[x] Move ContextLock() definition to Pipeline, probably.
[x] Make graceful termination work, for some reason it kinda doesn't right now
[ ] Get the workers to run in threads (Optional) (Right now it's commented out, because it doesn't work)
[ ] I have performed a self-review of the changes
To Consider
PollingMessengerInterface changed required "request/respond" methods, they must be changed in the child classes as well.
connect() methods for different Interface classes require different arguments, which is handled by a bunch of "if" statements in run_in_foreground() at the MessengerInterface class. There has to be a better way.
Add more tests. This is a core part of the program unit-tested only by a few simple tests. Although, I don't know, maybe this is good as is.
Update API reference / tutorials / guides
Search for references to changed entities in the codebase
Description
PollingMessengerInterface
class. Now requests are put in a queue, then done by 'workers', so that requests from several context_id's can be processed asynchronously. And a few other reasons that are explained in theTriggers
PR, I think.MessengerInterface
. When SIGINT is received, instead of abruptly terminating,shutdown()
fromMessengerInterface
is called, gracefully shutting down the program. All requests received prior to that are processed normally, then the program shuts down.MessengerInterface
base class, so thatconnect()
is run as an async task, not blocking the code.Checklist
To Consider
connect()
methods for different Interface classes require different arguments, which is handled by a bunch of "if" statements inrun_in_foreground()
at theMessengerInterface
class. There has to be a better way.