martin-saurer / jkernel

Jupyter Notebook / J Integration
GNU General Public License v3.0
44 stars 15 forks source link

Error processing plot and bitmap #15

Closed tingtron closed 4 years ago

tingtron commented 4 years ago

In jkernel.py there is code, which attempts to remove plot HTML and bitmap image files while they are still open (in both places in code):

                            with open(imgnam,'rb') as fp:
                                imgdat = base64.b64encode(fp.read()).decode()
                                os.remove(imgnam)

which causes the following error:

JKernel: Internal Error.
[WinError 32] The process cannot access the file because it is being used by another process: '...user\\temp\\plot.html'

This is easily fixed by indenting the "remove()" line of code back, so it happens after the file is closed:

                            with open(imgnam,'rb') as fp:
                                imgdat = base64.b64encode(fp.read()).decode()
                            os.remove(imgnam)
martin-saurer commented 4 years ago

Thanks! Fixed in latest upload.