当前位置: 首页 > 工具软件 > pyftpdlib > 使用案例 >

服务器ftp网站怎么临时关闭,如何停止pyftpdlib FTP服务器?

盖嘉庆
2023-12-01

我刚开始使用pyftpdlib。我首先要做的是使用示例服务器并将其包装在一个线程中。但是如果我运行这个脚本就不会退出:from pyftpdlib.authorizers import DummyAuthorizer

from pyftpdlib.handlers import FTPHandler

from pyftpdlib.servers import FTPServer

import logging

import threading

class FtpThread(threading.Thread):

def __init__(self, user_list):

self.user_list = user_list

self.killswitch = 0

threading.Thread.__init__(self)

def run(self,*args,**kwargs):

authorizer = DummyAuthorizer()

authorizer.add_user('user', 'bla', '/home/user/git/verteilerCore2/default_basedir/in/1/', perm='elradfmwM')

handler = FTPHandler

handler.authorizer = authorizer

logging.basicConfig(filename='/var/log/verteiler_ftp.log', level=logging.INFO)

handler.banner = "pyftpdlib based ftpd ready."

address = ('', 21)

self.server = FTPServer(address, handler)

self.server.max_cons = 256

self.server.max_cons_per_ip = 5

self.server.serve_forever()

def stop(self):

self.server.close_all()

def main():

ftp_server = FtpThread("")

ftp_server.start()

import time

time.sleep(1)

ftp_server.stop()

if __name__ == '__main__':

main()

我该怎么做才能让服务器永远停止?调用“close\u all”将停止服务器服务,但整个脚本不会退出:(

 类似资料: