MilesCranmer / PySR

High-Performance Symbolic Regression in Python and Julia
https://astroautomata.com/PySR
Apache License 2.0
2.32k stars 211 forks source link

[BUG]: BlockingIOError #412

Open MilesCranmer opened 1 year ago

MilesCranmer commented 1 year ago

First mentioned by @villrv in #411

Looks like it shows up sometimes for me as well. For example:

  File "/Users/mcranmer/Documents/PySR/.venv/bin/ipython", line 8, in <module>
    sys.exit(start_ipython())
  File "/Users/mcranmer/Documents/PySR/.venv/lib/python3.10/site-packages/IPython/__init__.py", line 129, in start_ipython
    return launch_new_instance(argv=argv, **kwargs)
  File "/Users/mcranmer/Documents/PySR/.venv/lib/python3.10/site-packages/traitlets/config/application.py", line 1043, in launch_instance
    app.start()
  File "/Users/mcranmer/Documents/PySR/.venv/lib/python3.10/site-packages/IPython/terminal/ipapp.py", line 318, in start
    self.shell.mainloop()
  File "/Users/mcranmer/Documents/PySR/.venv/lib/python3.10/site-packages/IPython/terminal/interactiveshell.py", line 888, in mainloop
    self.interact()
  File "/Users/mcranmer/Documents/PySR/.venv/lib/python3.10/site-packages/IPython/terminal/interactiveshell.py", line 870, in interact
    print(self.separate_in, end='')
BlockingIOError: [Errno 35] write could not complete without blocking
Error in sys.excepthook:
Traceback (most recent call last):
  File "/Users/mcranmer/Documents/PySR/.venv/lib/python3.10/site-packages/IPython/core/application.py", line 286, in excepthook
    return crashhandler.crash_handler_lite(etype, evalue, tb)
  File "/Users/mcranmer/Documents/PySR/.venv/lib/python3.10/site-packages/IPython/core/crashhandler.py", line 226, in crash_handler_lite
    traceback.print_exception(etype, evalue, tb)
  File "/Users/mcranmer/.pyenv/versions/3.10.10/lib/python3.10/traceback.py", line 121, in print_exception
    print(line, file=file, end="")
BlockingIOError: [Errno 35] write could not complete without blocking

Original exception was:
Traceback (most recent call last):
  File "/Users/mcranmer/Documents/PySR/.venv/bin/ipython", line 8, in <module>
    sys.exit(start_ipython())
  File "/Users/mcranmer/Documents/PySR/.venv/lib/python3.10/site-packages/IPython/__init__.py", line 129, in start_ipython
    return launch_new_instance(argv=argv, **kwargs)
  File "/Users/mcranmer/Documents/PySR/.venv/lib/python3.10/site-packages/traitlets/config/application.py", line 1043, in launch_instance
    app.start()
  File "/Users/mcranmer/Documents/PySR/.venv/lib/python3.10/site-packages/IPython/terminal/ipapp.py", line 318, in start
    self.shell.mainloop()
  File "/Users/mcranmer/Documents/PySR/.venv/lib/python3.10/site-packages/IPython/terminal/interactiveshell.py", line 888, in mainloop
    self.interact()
  File "/Users/mcranmer/Documents/PySR/.venv/lib/python3.10/site-packages/IPython/terminal/interactiveshell.py", line 870, in interact
    print(self.separate_in, end='')
BlockingIOError: [Errno 35] write could not complete without blocking

This is with Julia 1.9. I didn't see it on Julia 1.10. I wonder if it's some conflict between the latest IPython versions and PyJulia?

MilesCranmer commented 1 year ago

I think this error happens when Julia encounters an error within a thread other than the main thread.

A workaround would be to suppress all output from individual threads, and print them in the main thread.

MilesCranmer commented 1 year ago

Need to find a reliable way to reproduce this in a unit test...