关闭python解释器可以使用_关闭时Python解释器崩溃

<>我在一个遗留的Python应用程序中,适当地关闭了一个非常大的C++扩展模块。翻译关机时我遇到了一个故障,我没有办法了,所以我希望你能帮我找出原因。在

以下是我目前收集到的信息:在Windows上运行python2.7.2,32位

由应用程序启动的所有C++线程都是(AAFICT)关闭并正确连接;

应用程序启动的所有Python线程都是(AFAICT)关闭并正确连接的(它们被标记为守护进程以避免挂起作为最后的手段,但它们都是连接的)

processexplorer(Sysinternals)显示少数线程的“起始地址”位于ntdll.dll!TpCallbackIndependent+0x238

Process Explorer显示一个线程,其“起始地址”位于ntdll.dll!RtlMoveMemory+x5a5

当应用程序退出时(成功加入所有线程之后),ntdll.dll中的线程仍在运行,退出状态为1

在发生这种情况时,我所有的日志记录和诊断工具都关闭了。在

这个TpCallbackIndependent的东西似乎与Windows Thread Pool API有关,这个应用程序使用的{a1}不是。如果对您有意义的话,我可以列出所有外部Python库,但我认为它们也没有使用它。在

编辑:可能的罪魁祸首是pycurl模块。一旦我发出第一个pycurl.Curl.perform(),RtlMoveMemory和{}线程就启动了。即使我调用pycurl.global_cleanup()(此时mswsock线程消失,RtlMoveMemory线程永远不会完成,TpCallbackIndependent也会虚假地出现并永远消失。在

pycurl.version打印“libcurl/7.20.1openssl/0.9.8qzlib/1.2.5”,我不知道pycurl的版本是什么(我只有.pyd文件)。在

编辑:下面是一个创建有问题线程的示例Pycurl程序。出于某种原因我无法解释,这个特殊的调用并没有崩溃。。。在import cStringIO

import pycurl

import sys

pycurl.global_init(pycurl.GLOBAL_DEFAULT)

try:

b = cStringIO.StringIO()

# Issue request.

c = pycurl.Curl()

try:

c.setopt(pycurl.CUSTOMREQUEST, 'GET')

c.setopt(c.URL, 'http://www.google.ca')

c.setopt(c.WRITEFUNCTION, b.write)

print 'Type anything to issue the request.'

sys.stdin.readline()

c.perform()

# Threads appear as a result of the `.perform()`

# operation. If you monitor the active threads

# in "process explorer", you see that the threads

# appear here.

finally:

c.close()

del c

finally:

print 'Type anything to cleanup.'

sys.stdin.readline()

pycurl.global_cleanup()

# If you're still looking at active threads in "process

# explorer", you see that some threads (the mswsock.dll

# thread in particular) have disappeared, but there are still

# weird TpCallbackIndependent threads showing up.

print 'Type anything to exit.'

sys.stdin.readline()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值