简体   繁体   English

致命的 Python 错误:在解释器关闭时无法获取 <_io.BufferedReader name=8> 的锁定,可能是由于守护线程

[英]Fatal Python error: could not acquire lock for <_io.BufferedReader name=8> at interpreter shutdown, possibly due to daemon threads

Running the following:运行以下:

import imageio

class vidrdf:
    def __init__(self, vidfile):
        self.vid = imageio.get_reader(vidfile,  'ffmpeg')

vidfile = 'movie.mov'
rdfobj = vidrdf(vidfile)

I get:我得到:

Fatal Python error: could not acquire lock for <_io.BufferedReader name=8> at interpreter shutdown, possibly due to daemon threads

Thread 0x00007fd2dc2a8700 (most recent call first):
  File “/path/miniconda3/envs/flower/lib/python3.7/site-packages/imageio_ffmpeg/_parsing.py", line 61 in run
  File "miniconda3/envs/flower/lib/python3.7/threading.py", line 926 in _bootstrap_inner
  File “/path/miniconda3/envs/flower/lib/python3.7/threading.py", line 890 in _bootstrap

Current thread 0x00007fd2f0bb9700 (most recent call first):
  File “/path/miniconda3/envs/flower/lib/python3.7/subprocess.py", line 1704 in _communicate
  File “/path/miniconda3/envs/flower/lib/python3.7/subprocess.py", line 939 in communicate
  File “/path/miniconda3/envs/flower/lib/python3.7/site-packages/imageio_ffmpeg/_io.py", line 193 in read_frames
  File “/path/miniconda3/envs/flower/lib/python3.7/site-packages/imageio/plugins/ffmpeg.py", line 342 in _close
  File “/path/miniconda3/envs/flower/lib/python3.7/site-packages/imageio/core/format.py", line 252 in close
  File “/path/miniconda3/envs/flower/lib/python3.7/site-packages/imageio/core/format.py", line 241 in __del__
Aborted (core dumped)

It doesn't happen if I try:如果我尝试,它不会发生:

import imageio

class vidrdf:
    def __init__(self, vidfile):
        self.vid = imageio.get_reader(vidfile,  'ffmpeg')

vidfile = 'movie.mov'
vidrdf(vidfile)

or或者

import imageio

class vidrdf:
    def __init__(self, vidfile):
        vid = imageio.get_reader(vidfile,  'ffmpeg')

vidfile = 'movie.mov'
rdfobj = vidrdf(vidfile)

So this is clearly an issue with copying the object.所以这显然是复制 object 的问题。 I've searched about daemon threads, but since I'm using imageio directly I can't figure out why and how to resolve it.我搜索了守护线程,但由于我直接使用 imageio,我无法弄清楚为什么以及如何解决它。 I would appreciate any recommendations.我将不胜感激任何建议。

The following seems to work, although I don't know why:以下似乎有效,虽然我不知道为什么:

import imageio
import copy

class vidrdf:
    def __init__(self, vidfile):
        vid = imageio.get_reader(vidfile,  'ffmpeg')
        self.vid = copy.copy(vid)


vidfile = 'movie.mov'
rdfobj = vidrdf(vidfile)

暂无
暂无

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

相关问题 致命的 Python 错误:无法为 &lt;_io.BufferedReader name=&#39; 获取锁<stdin> &#39;&gt; 在解释器关闭时,可能是由于守护线程 - Fatal Python error: could not acquire lock for <_io.BufferedReader name='<stdin>'> at interpreter shutdown, possibly due to daemon threads 如何修复“致命 Python 错误:_enter_buffered_busy:无法获取 &lt;_io.BufferedWriter name=”的锁定<stdout> '&gt; 在解释器关闭时' 错误?</stdout> - How to fix a 'fatal Python error: _enter_buffered_busy: could not aquire lock for <_io.BufferedWriter name='<stdout>'> at interpreter shutdown' error? 解开“ _io.BufferedReader”错误 - unpickling '_io.BufferedReader' error ResourceWarning:未关闭的文件 &lt;_io.BufferedReader name=4&gt; - ResourceWarning: unclosed file <_io.BufferedReader name=4> Python - 使用 _io.BufferedReader 获取 TypeError - Python - Getting TypeError with _io.BufferedReader &#39;io.BufferedReader&#39;对象不可下标&#39;错误 - 'io.BufferedReader' object is not subscriptable' error Python3:Reportlab图像 - ResourceWarning:未闭合文件&lt;_io.BufferedReader name = ...&gt; - Python3: Reportlab Image - ResourceWarning: unclosed file <_io.BufferedReader name=…> 尝试在 Python 中使用 matplotlib 保存图形动画 - “无效的文件对象:&lt;_io.BufferedReader name=76&gt;” - Trying to save an animated of graph with matplotlib in Python - "Invalid file object: <_io.BufferedReader name=76>" Pyqt5线程无法正常工作(致命的Python错误:无法获取锁) - Pyqt5 threading can't work (Fatal Python error: could not acquire lock) Python-如何在io.BufferedReader中使用自定义buffer_size? - Python - How to use custom buffer_size in io.BufferedReader?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM