Jupyter并发测试以后出现EOFError marshal data too short

Jupyter 并发测试以后出现EOFError: marshal data too short

背景

由于项目需求需要用户能进行网页在线运行python代码程序,调研后决定使用Jupyter的服务接口实现此功能,目前使用docker进行容器化部署,测试针对次服务进行并发测试。测试并发过程中,导致kernels已经达到顶峰值,然后我暴力关掉所有的kernels以后,再进行使用的时候,出现EOFError: marshal data too short

现象

分析与解决方案

通过异常日志分析,查到这篇文章https://stackoverflow.com/questions/50391941/eoferror-marshal-data-too-short说是要pyc文件损坏,需要删除`__pycache__`文件夹下的文件。

从日志分析需要删除ipykernelIPythonjedi下的缓存文件,使用一下命令查询并删除

shell 复制代码
find /usr/local/lib/python3.11/dist-packages/ipykernel -name __pycache__ | grep IPython -exec rm -r {} +

删除完后发现还是解决不了问题。最后想了一个暴力的解决方案,直接删除dist-packagess 目录下的所有的__pycache__文件夹。

shell 复制代码
find . -type d -name "__pycache__" -exec rm -r {} +

再尝试运行一下,完美解决问题!

相关推荐
AI探索者3 小时前
LangGraph StateGraph 实战:状态机聊天机器人构建指南
python
AI探索者3 小时前
LangGraph 入门:构建带记忆功能的天气查询 Agent
python
FishCoderh4 小时前
Python自动化办公实战:批量重命名文件,告别手动操作
python
躺平大鹅4 小时前
Python函数入门详解(定义+调用+参数)
python
曲幽5 小时前
我用FastAPI接ollama大模型,差点被asyncio整崩溃(附对话窗口实战)
python·fastapi·web·async·httpx·asyncio·ollama
两万五千个小时9 小时前
落地实现 Anthropic Multi-Agent Research System
人工智能·python·架构
哈里谢顿11 小时前
Python 高并发服务限流终极方案:从原理到生产落地(2026 实战指南)
python
用户8356290780511 天前
无需 Office:Python 批量转换 PPT 为图片
后端·python
markfeng81 天前
Python+Django+H5+MySQL项目搭建
python·django
GinoWi1 天前
Chapter 2 - Python中的变量和简单的数据类型
python