Hi Nandha,
You've got several alternatives here:
- If your code doesn't need to be run all the time while reactor runs, you could schedule your code to run periodically in reactor, e.g.:
def my_python_code():
#Your code here
run_again_in_seconds = #calculate
reactor.callLater(run_again_in_seconds, my_python_code)
reactor.callLater(0, my_python_code) #First run of your python code
reactor.run()
If run_again_in_seconds is known beforehand, you can use task.LoopingCall to call my_python_code periodically.
Note that my_python_code should execute it's job fast (no more than several seconds) for your ssh server which runs on reactor to remain responsive. - If your python code can't do it's job fast, then you need to run it in a separate thread, see the "Using threads in Twisted" article.
--
Kind regards, Roman Mescheryakov
21.11.2017, 06:17, "Nandha Kumar" <nandhakumarsath...@gmail.com>:
Hi guys,
I'm using twisted to host an ssh server.. My requirement that the python
code I did needs to start the reactor and come out of the execution and
needs to stop the reactor once stop is called.. But since the reactor.
Run() seems to be a blocking one.. It isn't moving forward after starting
the reactor.. Any work around on this would be appreciated..
Regards,
Nandha Kumar S
_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python