X
X
Xymis2021-07-08 15:10:21
Python
Xymis, 2021-07-08 15:10:21

How to implement the following asynchronous construct?

Hello!
I can’t implement the following idea: We need
a small server on sockets for a TCP connection that will control the function.
For the most part, the generator function (from an iterator) passes through an array that is too large . If a pause message is received on the socket, stop . If a stop message is received on the socket, abort the passage of the link. So far, I have come to the following idea: The main event loop, it initially has a coroutine on handle http

When you get start, you need to launch the second coroutine and throw it into the loop so that there is competition (one coroutine is waiting for a message, the second one runs through the list)
Well, process user requests accordingly

I can run two coroutines at most (but not because a request has come)
Tell , how to implement communication between two coroutines in python, I will be very grateful
I will be very happy with a code example
Thank you in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dooMoob, 2021-07-08
@Xymis

1) the generator must be asynchronous, otherwise all this will not work
2) communication is the same as in the case of threads - queues, global variables, etc

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question