Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asynchronous management of events #26

Open
christian-pinto opened this issue May 17, 2024 · 5 comments
Open

Asynchronous management of events #26

christian-pinto opened this issue May 17, 2024 · 5 comments
Assignees

Comments

@christian-pinto
Copy link
Collaborator

When the sunfish core receives an event it handles it synchronously and the event sender waits for the entire time it gets processed. Events should return immediately for the client and be processed by a thread (or similar).

@christian-pinto
Copy link
Collaborator Author

@mjaguil

@mjaguil
Copy link
Collaborator

mjaguil commented May 28, 2024

I will be working on threads and thread locking

@christian-pinto
Copy link
Collaborator Author

While making events asynchronous we should also look into multi-threading in general.

The two places where multithreading is needed are:

  1. The REST API interface
    • Clients use the Sunfish RESTful API, with potentially multiple clients doing it in parallel. Flask restful is already supporting multi threading at the API interface level.
  2. Events handling
    • Clients/agents send an event to sunfish (POST) and are released immediately without waiting for the event to be processed.

For both the above we need to make sure that both the sunfish core library and the event interface are thread safe. This includes that the storage backends are also thread safe.

@christian-pinto
Copy link
Collaborator Author

A way of working towards thread safe-ness is to use a database for storing the redfish tree.

We should evaluate a couple of alternatives:

  • Redis
  • Cassandra
  • ETCD
  • MongoDB
  • others?

@christian-pinto
Copy link
Collaborator Author

I have been evaluating the usage of python threads vs adopting the newer asyncio library. I personally prefer using asyncio because it is better integrated with python and allows us to catch exceptions from asynchronous co-routines. Unlike threads where exceptions can be caught only the a join is executed on the main thread.

Implementation with threads is already available but lacks catching the above mentioned exceptions. On the other hand switching to an asyncio based implementation would require a substantial overhaul of the entire library as most of the plugins and functionalities would have to adopt the asynchronous pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants