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 {} +

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

相关推荐
曲幽3 小时前
FastAPI + PostgreSQL 实战:从入门到不踩坑,一次讲透
python·sql·postgresql·fastapi·web·postgres·db·asyncpg
用户8356290780518 小时前
使用 C# 在 Excel 中创建数据透视表
后端·python
码路飞11 小时前
FastMCP 实战:一个 .py 文件,给 Claude Code 装上 3 个超实用工具
python·ai编程·mcp
dev派13 小时前
AI Agent 系统中的常用 Workflow 模式(2) Evaluator-Optimizer模式
python·langchain
前端付豪15 小时前
AI 数学辅导老师项目构想和初始化
前端·后端·python
用户03321266636715 小时前
将 PDF 文档转换为图片【Python 教程】
python
悟空爬虫16 小时前
UV实战教程,我啥要从Anaconda切换到uv来管理包?
python
dev派16 小时前
AI Agent 系统中的常用 Workflow 模式(1)
python·langchain
明月_清风18 小时前
从“能用”到“专业”:构建生产级装饰器与三层逻辑拆解
后端·python
曲幽1 天前
数据库实战:FastAPI + SQLAlchemy 2.0 + Alembic 从零搭建,踩坑实录
python·fastapi·web·sqlalchemy·db·asyncio·alembic