Python script dies due to WebSocket closing "abnormally"
Thanks for filing an issue! Please answer the questions below so I can help you.
- iTerm2 version: Build 3.3.0beta2
- OS version: macOS Mojave 10.14.5 Beta (18F96h)
- Attach here (drag-drop from finder into this window)
- Attach a debug log, if possible. Instructions at https://iterm2.com/debuglog
- Are you reporting a performance issue, excessive CPU usage, or a hang? Please attach a sample. Instructions at https://gitlab.com/gnachman/iterm2/wikis/HowToSample
- Are you reporting a crash? Please attach the crash log. Instructions at https://gitlab.com/gnachman/iterm2/wikis/crash-logs
- Are you reporting excessive memory usage? Please attach a heap analysis: https://gitlab.com/gnachman/iterm2/wikis/heapshot
Detailed steps to reproduce the problem:
- Run the AutoLaunch script.
- Wait.
What happened:
The script dies at some point with websockets.exceptions.ConnectionClosed: WebSocket connection is closed: code = 1006 (connection closed abnormally [internal]), no reason
.
What should have happened:
Nothing, it should keep running.
(Context, because I don't see where to put this):
I'm running a script that changes my theme based on effectiveAppearance
, which is derived from the example you have online. I have it AutoLaunch and run in the background but it keeps dying with is backtrace:
Log
4/6, 05:25:31: /opt/local/bin/bash -c /Applications/iTerm.app/Contents/Resources/it2_api_wrapper.sh /Users/saagarjha/Library/ApplicationSupport/iTerm2/iterm2env/versions/3.7.2/bin/python3 /Users/saagarjha/Library/ApplicationSupport/iTerm2/Scripts/AutoLaunch/theme.py
4/6, 05:25:31: + unset PYTHONPATH
4/6, 05:25:31: + export PYTHONUNBUFFERED=1
4/6, 05:25:31: + PYTHONUNBUFFERED=1
4/6, 05:25:31: + /Users/saagarjha/Library/ApplicationSupport/iTerm2/iterm2env/versions/3.7.2/bin/python3 /Users/saagarjha/Library/ApplicationSupport/iTerm2/Scripts/AutoLaunch/theme.py
4/6, 05:25:31: Connection accepted: Script launched by user action
4/6, 06:42:57: Executing <Task finished coro=<Connection._async_dispatch_to_helper() done, defined at /Users/saagarjha/Library/ApplicationSupport/iTerm2/iterm2env/versions/3.7.2/lib/python3.7/site-packages/iterm2/connection.py:221> result=None created at /Users/saagarjha/Library/ApplicationSupport/iTerm2/iterm2env/versions/3.7.2/lib/python3.7/site-packages/iterm2/connection.py:132> took 0.422 seconds
4/6, 06:43:10: Executing <Handle _SelectorSocketTransport._read_ready() created at /Users/saagarjha/Library/ApplicationSupport/iTerm2/iterm2env/versions/3.7.2/lib/python3.7/asyncio/selector_events.py:249> took 0.310 seconds
4/6, 06:43:11: Executing <Handle <TaskWakeupMethWrapper object at 0x10e8d2b28>(<_GatheringFu.../tasks.py:615>) created at /Users/saagarjha/Library/ApplicationSupport/iTerm2/iterm2env/versions/3.7.2/lib/python3.7/asyncio/tasks.py:711> took 1.170 seconds
4/6, 06:45:14: Executing <Handle _SelectorSocketTransport._read_ready() created at /Users/saagarjha/Library/ApplicationSupport/iTerm2/iterm2env/versions/3.7.2/lib/python3.7/asyncio/selector_events.py:249> took 0.168 seconds
4/6, 06:45:36: Executing <Handle <TaskWakeupMethWrapper object at 0x10e6b4318>(<Future finis...events.py:396>) created at /Users/saagarjha/Library/ApplicationSupport/iTerm2/iterm2env/versions/3.7.2/lib/python3.7/asyncio/futures.py:288> took 0.183 seconds
4/6, 06:49:22: Traceback (most recent call last):
4/6, 06:49:22: File "/Users/saagarjha/Library/ApplicationSupport/iTerm2/iterm2env/versions/3.7.2/lib/python3.7/site-packages/websockets/protocol.py", line 674, in transfer_data
4/6, 06:49:22: message = yield from self.read_message()
4/6, 06:49:22: File "/Users/saagarjha/Library/ApplicationSupport/iTerm2/iterm2env/versions/3.7.2/lib/python3.7/site-packages/websockets/protocol.py", line 742, in read_message
4/6, 06:49:22: frame = yield from self.read_data_frame(max_size=self.max_size)
4/6, 06:49:22: File "/Users/saagarjha/Library/ApplicationSupport/iTerm2/iterm2env/versions/3.7.2/lib/python3.7/site-packages/websockets/protocol.py", line 815, in read_data_frame
4/6, 06:49:22: frame = yield from self.read_frame(max_size)
4/6, 06:49:22: File "/Users/saagarjha/Library/ApplicationSupport/iTerm2/iterm2env/versions/3.7.2/lib/python3.7/site-packages/websockets/protocol.py", line 884, in read_frame
4/6, 06:49:22: extensions=self.extensions,
4/6, 06:49:22: File "/Users/saagarjha/Library/ApplicationSupport/iTerm2/iterm2env/versions/3.7.2/lib/python3.7/site-packages/websockets/framing.py", line 99, in read
4/6, 06:49:22: data = yield from reader(2)
4/6, 06:49:22: File "/Users/saagarjha/Library/ApplicationSupport/iTerm2/iterm2env/versions/3.7.2/lib/python3.7/asyncio/streams.py", line 679, in readexactly
4/6, 06:49:22: await self._wait_for_data('readexactly')
4/6, 06:49:22: File "/Users/saagarjha/Library/ApplicationSupport/iTerm2/iterm2env/versions/3.7.2/lib/python3.7/asyncio/streams.py", line 473, in _wait_for_data
4/6, 06:49:22: await self._waiter
4/6, 06:49:22: concurrent.futures._base.CancelledError
4/6, 06:49:22:
4/6, 06:49:22: The above exception was the direct cause of the following exception:
4/6, 06:49:22:
4/6, 06:49:22: Traceback (most recent call last):
4/6, 06:49:22: File "/Users/saagarjha/Library/ApplicationSupport/iTerm2/iterm2env/versions/3.7.2/lib/python3.7/site-packages/iterm2/connection.py", line 120, in _async_dispatch_forever
4/6, 06:49:22: data = await self.websocket.recv()
4/6, 06:49:22: File "/Users/saagarjha/Library/ApplicationSupport/iTerm2/iterm2env/versions/3.7.2/lib/python3.7/site-packages/websockets/protocol.py", line 434, in recv
4/6, 06:49:22: yield from self.ensure_open()
4/6, 06:49:22: File "/Users/saagarjha/Library/ApplicationSupport/iTerm2/iterm2env/versions/3.7.2/lib/python3.7/site-packages/websockets/protocol.py", line 658, in ensure_open
4/6, 06:49:22: ) from self.transfer_data_exc
4/6, 06:49:22: websockets.exceptions.ConnectionClosed: WebSocket connection is closed: code = 1006 (connection closed abnormally [internal]), no reason
4/6, 06:49:43:
4/6, 06:49:43: Connection closed.