Multi-process is among multiple processes, the blocking of one process will not affect other processes. For example, performing a large number of calculation operations in one process will not have a major impact on other processes.
Coroutine is in a thread. If one task in the coroutine is blocked, other tasks will also be affected. For example, if a large number of calculation operations are performed in a task, this task will block other tasks.
So coroutines are not suitable for processing computing-intensive tasks, but are suitable for processing IO-intensive tasks. Because Ctrip cooperates with asynchronous IO, you can get the pleasure of synchronous programming without blocking the process.
Are you sure the code is correct? Why do you feel that multiprocess calculates it twice...
Multi-process is among multiple processes, the blocking of one process will not affect other processes. For example, performing a large number of calculation operations in one process will not have a major impact on other processes.
Coroutine is in a thread. If one task in the coroutine is blocked, other tasks will also be affected. For example, if a large number of calculation operations are performed in a task, this task will block other tasks.
So coroutines are not suitable for processing computing-intensive tasks, but are suitable for processing IO-intensive tasks. Because Ctrip cooperates with asynchronous IO, you can get the pleasure of synchronous programming without blocking the process.