K
K
Kirill2020-05-07 03:39:00
Python
Kirill, 2020-05-07 03:39:00

How to implement multithreading?

It is necessary to implement some real multithreading in the script.
The essence of the script:
The script expects a command with a number. As soon as the number is received, the script starts parsing the page on the site using the number (it doesn't matter though). BUT! While parsing a page, the script MUST continue to wait and accept values ​​from users and start parsing other pages in parallel.
Attention to the question - how to do it?
Can you recommend any libraries or example. The threading library does not seem to suit me, because in fact it does not seem to make a multithread, but stops the rest of the threads while one of them is running.
If I'm wrong, tell me.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xmoonlight, 2020-05-07
@xmoonlight

asyncio is all you need.

asyncio is a library to write concurrent code using the async/await syntax.
asyncio is used as a foundation for multiple Python asynchronous frameworks that provide high-performance network and web-servers, database connection libraries, distributed task queues , etc.
asyncio is often a perfect fit for IO-bound and high-level structured network code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question