简体   繁体   English

测试期间线程异常

[英]Exception in thread during testing

I run my tests: 我运行测试:

manage.py test myapp

and at the end I get: 最后我得到:

Ran 22 tests in 7.243s 在7.243秒内进行了22次测试

OK

Exception in thread Thread-22 (most likely raised during interpreter shutdown) 线程Thread-22中的异常(很可能在解释器关闭期间引发)

or 要么

Ran 22 tests in 7.243s 在7.243秒内进行了22次测试

OK

Unhandled exception in thread started by < function observe at ... > ... 由<函数启动的线程中未处理的异常在...> ...观察

or simple 或简单

Ran 22 tests in 7.243s 在7.243秒内进行了22次测试

OK

Function observe() is not called during testing (it is a separate thread), but I am getting above exceptions... 在测试过程中未调用函数observe() (它是一个单独的线程),但是我遇到了异常...

What should I do in order to tests omitted this function? 为了测试省略了该功能我该怎么办?

Wrapping the run() method of the threads into try / except can help: 将线程的run()方法包装为try / except可以帮助:

import traceback

class MyThread(Thread):
  def run(self):
    try:
      oldRun(self)
    except:
      traceback.print_exc()

  def oldRun(self):
    # insert here the code from the original run function

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 得到异常错误“Thread-13线程中的异常(最有可能在解释器关闭期间引发)” - Got Exception Error “Exception in thread Thread-13 (most likely raised during interpreter shutdown)” 得到异常错误“线程Thread-1中的异常(很可能在解释器关闭期间引发)”使用Paramiko - Got Exception Error “Exception in thread Thread-1 (most likely raised during interpreter shutdown)” which using Paramiko 线程 Thread-1 中的 Python 异常(最有可能在解释器关闭期间引发)? - Python Exception in thread Thread-1 (most likely raised during interpreter shutdown)? Pycassa,线程池,“线程Thread-3中的异常(很可能在解释器关闭期间引发):” - Pycassa, threadpool, “Exception in thread Thread-3 (most likely raised during interpreter shutdown):” 线程 Thread-1 中的异常: - Exception in thread Thread-1: 线程pydevd.CommandThread中的异常(很可能在解释器关闭期间引发)-PyDev - Exception in thread pydevd.CommandThread (most likely raised during interpreter shutdown) - PyDev 测试期间LSTM出错 - Error in LSTM during testing 调用gensim时发生异常? - Exception during calling gensim? matplotlib animation 期间的异常 - Exception during matplotlib animation 在记录期间引发异常 - Raising exception during logging
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM