python如何停止子线程_【已解决】python 如何结束子线程呢

本文介绍了如何在Python中启动和停止FTP服务,并提供了使用`_async_raise`函数配合`SystemExit`异常来停止子线程的方法。通过创建线程并设置daemon属性,然后在需要停止子线程时调用`stop_thread`函数,实现对子线程的控制。
摘要由CSDN通过智能技术生成

复制内容到剪贴板

代码:# -*- coding:utf-8 -*-

import wx

import os

import sys

import configparser

import ftpserver

import time

import threading

import ctypes

import inspect

def startftp(event):#点击 启动FTP 按钮事件

global t

if startbutton.GetLabel()=='启动FTP':

startbutton.SetLabel('停止FTP')

config=configparser.ConfigParser()

config.add_section('ftpd')

config.set('ftpd','anonymous',str(not check.GetValue()))

config.set('ftpd','user',usertext.GetValue())

config.set('ftpd','password',passtext.GetValue())

config.set('ftpd','port',porttext.GetValue())

config.set('ftpd','dir',dirtext.GetValue())

with open('config.ini','w') as conf:

config.write(conf)

time.sleep(1)

t=threading.Thr

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值