A
A
Alexey Poloz2017-10-15 15:05:31
Python
Alexey Poloz, 2017-10-15 15:05:31

Python Why don't nested functions work when multithreaded?

It is necessary that two subroutines work in parallel I
use multiprocessing

p1 = Process(target=monitor)
p2 = Process(target=bot)

These programs have plug-in libraries, inside which there are still connections.
When I run these files separately, everything works fine.
But when I run them in threads, the programs themselves work, but when it comes to functions from other nested libraries, it freezes and does not give an answer
. how to correct it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Vasiliev, 2017-10-19
@qmax

For anything to work in multithreading, all this code must be specially adapted for multithreading, along with all the modules and libraries it uses, including extensions on these. If at least some of this is not thread-safe, then the whole code will not be thread-safe.
Use better multiprocessing.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question