From 000876dd865216a3d86113f23132e62138b5546e Mon Sep 17 00:00:00 2001 From: Oscar Campos Date: Sun, 24 Aug 2014 13:48:33 +0100 Subject: [PATCH] Workaround for #190 and #207 For some reason, when Package Control updates Anaconda in Windows, the winsocks enter in an inconsistent state that produce several problems, being the most critical one a total unresponsiveness of the ST3. What Package Control do is just disable the package, install the update and then re-enable de package, if you do that manually, it seems to work just fine. I am being able to reproduce this behaviour after anaconda automatic updates only. The commit just detect when a socket enter in inconsistent state, then show an error message to the user and stop the asynchronous poll (this should not make ST3 unresponsive). --- anaconda_lib/ioloop.py | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/anaconda_lib/ioloop.py b/anaconda_lib/ioloop.py index 69e15481..319c70f0 100644 --- a/anaconda_lib/ioloop.py +++ b/anaconda_lib/ioloop.py @@ -274,24 +274,39 @@ def loop(): """Main event loop """ + def restart_poll(error): + print('Unhandled exception in poll, restarting the poll request') + print(error) + for traceback_line in traceback.format_exc().splitlines(): + print(traceback_line) + + with IOHandlers()._lock: + for handler in IOHandlers()._handler_pool.values(): + handler.close() + IOHandlers()._handler_pool = {} + def inner_loop(): while NOT_TERMINATE: try: poll() time.sleep(0.01) + except OSError as error: + if os.name != 'posix' and error.errno == os.errno.WSAENOTSOCK: + msg = ( + 'Unfortunately, the Windows socket is in inconsistent' + ' state, restart your sublime text 3. If the problem ' + 'persist, fill an issue report on:' + ' https://github.com/DamnWidget/anaconda/issues' + ) + print(msg) + import sublime + sublime.error_message(msg) + terminate() + else: + restart_poll(error) except Exception as error: - print( - 'Unhandled exception in poll, restarting the poll request' - ) - print(error) - for traceback_line in traceback.format_exc().splitlines(): - print(traceback_line) - - with IOHandlers()._lock: - for handler in IOHandlers()._handler_pool.values(): - handler.close() - IOHandlers()._handler_pool = {} + restart_poll(error) # cleanup for handler in IOHandlers()._handler_pool.values():