Answer the question
In order to leave comments, you need to log in
How to complete the subtraction of a generator from another instance of the program?
Hello everybody.
Working with paramiko and channels (web-socket) in Django.
Implemented a class for creating a connection and executing commands on the server via paramiko.Transport.
An instance of this class in this context is executer.
I create an instance of the class - executer, execute a command, the result of which goes to self.session.recv (which I am going to read through the next generator method).
Generator method from the executer class:
def gen(self):
while not self.session.exit_status_ready():
yield self.session.recv(self.RECV_BYTES).decode("utf-8") \
or self.session.recv_stderr(self.RECV_BYTES).decode("utf-8")
for message in self.executer.gen:
self.send(text_data=json.dumps({
'message': str(message)
}))
Answer the question
In order to leave comments, you need to log in
You need a second thread that will listen to the connection (TCP, HTTP, Web Socket - it doesn't matter) and when accessing it - call close()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question