Cylc-flow: Replace scheduler.py main loop by asyncio loop

Created on 19 Nov 2018  路  4Comments  路  Source: cylc/cylc-flow

When working on the Tornado PoC (#2825) one of the tasks involved making the scheduler.py main loop to run alongside Tornado's main loop (i.e. an asyncio loop since Python 3.x).

It worked after replacing scheduler.py main loop by Tornado's loop. However, there are several blocking calls in Cylc's Suite Server Program main loop; calls to read and write files to disk, calls to sqlite, even network calls. These could all be parallelized through coroutines with asyncio.

I spent some time looking at the code, and I think it could work. Though I would need more time with the code in order to do some further tests and come up with some benchmarks and pros/cons.

efficiency speculative

Most helpful comment

Agreed on principle.

Just another emphasis on the logic that writes to the primary SQLite file. It is important that we design the asynchronous to block the suite work flow to ensure the integrity of the persistent data for unscheduled stop+restart. Obviously, we can still design this logic to be asynchronous relative to the web server, but have enough logic to stop the suite workflow from moving on until we have a successful write to the primary SQLite file.

All 4 comments

Agreed on principle.

Just another emphasis on the logic that writes to the primary SQLite file. It is important that we design the asynchronous to block the suite work flow to ensure the integrity of the persistent data for unscheduled stop+restart. Obviously, we can still design this logic to be asynchronous relative to the web server, but have enough logic to stop the suite workflow from moving on until we have a successful write to the primary SQLite file.

I think this might be superseded by a new issue to do the same but with focus on pyzmq/ZeroMQ, and priority queues? If that's the case, we can close this one :+1:

Very different scope here, I suppose. The main loop is not just about communication, so we may want to repurpose this issue to have an emphasis on the parts that are not to do with 0mq. Unless the new issue is going to fully supersede those as well?

Superseded by #3495

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hjoliver picture hjoliver  路  5Comments

kinow picture kinow  路  4Comments

oliver-sanders picture oliver-sanders  路  4Comments

kinow picture kinow  路  4Comments

oliver-sanders picture oliver-sanders  路  3Comments