lichess-bot-devs / lichess-bot

A bridge between Lichess bots and chess engines
GNU Affero General Public License v3.0
764 stars 448 forks source link

lichess-bot does not survive lichess reboots #798

Closed alip closed 1 year ago

alip commented 1 year ago

Describe the bug When lichess reboots when an engine game is present, lichess-bot spews this traceback and stalls forever:

         lichess-bot.py:695
                    INFO     Searching for wtime 126440 btime 57425 for game u3Bd9Nfp                                                                                                                                     engine_wrapper.py:670
Process Process-2:
Traceback (most recent call last):
  File "/usr/x86_64-pc-linux-musl/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/usr/x86_64-pc-linux-musl/lib/python3.9/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/alip/src/lichess-bot/lichess-bot.py", line 104, in watch_control_stream
    control_queue.put_nowait({"type": "terminated", "error": error})
  File "<string>", line 2, in put_nowait
  File "/usr/x86_64-pc-linux-musl/lib/python3.9/multiprocessing/managers.py", line 809, in _callmethod
    conn.send((self._id, methodname, args, kwds))
  File "/usr/x86_64-pc-linux-musl/lib/python3.9/multiprocessing/connection.py", line 206, in send
    self._send_bytes(_ForkingPickler.dumps(obj))
  File "/usr/x86_64-pc-linux-musl/lib/python3.9/multiprocessing/reduction.py", line 51, in dumps
    cls(buf, protocol).dump(obj)
TypeError: cannot pickle '_thread.lock' object

The traceback is not always the same, the other bot playing the same game had this traceback:

                    INFO     Searching for wtime 113885 btime 58460 for game u3Bd9Nfp
      engine_wrapper.py:670
[08/08/23 04:39:34] INFO     Evaluation: 0.0
      engine_wrapper.py:320
                    INFO     Depth: 56
      engine_wrapper.py:320
                    INFO     Nodes: 85.5M
      engine_wrapper.py:320
                    INFO     Speed: 4.7Mnps
      engine_wrapper.py:320
                    INFO     Pv: 67. Rga5 Kh6 68. Rc5 Rd6 69. Re5 Rf6 70. Ra3 c5 71. Rd5 Rfxa6 72. Rxa6+ Rxa6 73. Rxd3 Rf6 74. Ne4 Re6 75. Rd6 Bf5 76. Rxe6+ Bxe6 77. Nxc5
      engine_wrapper.py:320
Process Process-2:
Traceback (most recent call last):
  File "/usr/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/usr/lib/python3.11/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/alip/src/lichess-bot/lichess-bot.py", line 104, in watch_control_stream
    control_queue.put_nowait({"type": "terminated", "error": error})
  File "<string>", line 2, in put_nowait
  File "/usr/lib/python3.11/multiprocessing/managers.py", line 821, in _callmethod
    conn.send((self._id, methodname, args, kwds))
  File "/usr/lib/python3.11/multiprocessing/connection.py", line 205, in send
    self._send_bytes(_ForkingPickler.dumps(obj))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/multiprocessing/reduction.py", line 51, in dumps
    cls(buf, protocol).dump(obj)
TypeError: cannot pickle 'SSLContext' object

To Reproduce Steps to reproduce the behavior:

  1. Run lichess-bot as usual
  2. Play a sufficiently long game on lichess
  3. Wait for lichess to reboot
  4. See error

Expected behavior Lichess-bot must reconnect to lichess after lichess reboots.

Logs N/A

Desktop (please complete the following information):

Additional context N/A

MarkZH commented 1 year ago

Please reopen if the problem happens again.