A major problem with the above code is that it is not using "classes" - it is declaring functions in the body of a class - the way it is, they nay are "methods", are functions even, who know nothing of the class within which they were declared. This ends up generating an artistic namespace, which works for those who will call these functions from outside, but it is very strange for when these "functions within the class" have to call each other, or share an "attribute": they will have to be prefixed with the class name in full.
The most appropriate way to do this would be to create a method __init__
in the classes, and put the class itself as target of the processes - in this way you will have a "zeroed" instance of each class in each process.
It might be interesting for you to read some documentation and get a better understanding of how this works. This article seems to be a good start (I didn’t read it carefully, but it seems to have the basics) http://pythonclub.com.br/introducao-classes-metodos-python-basico.html
If you find it difficult to use classes and methods in a way that makes sense, remember that Python does not require you to make use of them when your architecture does not need them: you can use simple functions. In your same code example, the functions themselves Telas
and Comunicacao
have no reason to call another function within the classes - they could perform the task directly.
After you fix this: the way to communicate data between different processes is by using the classes Multiprossecing.Queue
and Multiprocessing.Pipe
- its use with a small example is documented here: https://docs.python.org/3/library/multiprocessing.html
Your example of code became so minimal that you don’t know what you would like to communicate from one side to the other so any example I created here would be equivalent to what is in the official Python documentation, above.
Can [Edit] your question and add code? Are lawsuits distinct or threads distinct?
– Woss
I edited the question!
– HelloWorld
@Andersoncarloswoss you know how to implement these classes?
– HelloWorld