i have a ftp server that uses a serve_forever command. this ftp service is called in a thread ,what i want to do is that i want to abruptly close the thread from the main thread ,when i hit the stop button on my GUI.
import os
import sqlite3
from pyftpdlib import ftpserver
def main():
authorizer = ftpserver.DummyAuthorizer()
#does something
address = ('127.0.0.1', 10221)
ftpd = ftpserver.FTPServer(address, handler)
# start ftp server
ftpd.serve_forever()
if __name__ == '__main__':
main()
this is my main thread which calls the ftp service
def start_ftp(self):
self.ftp_status.setText("Running")
self.ftp_status.setStyleSheet("Background : light green")
#thread.start_new_thread( FtpService )
def stop_ftp(self):
self.ftp_status.setText("Stopped")
self.ftp_status.setStyleSheet("Background : red")
#what should i put here for the desired result
please help guys