Skip to content

Commit 0a84c8f

Browse files
committed
catch ymq exception
1 parent 99848a7 commit 0a84c8f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/scaler/worker/worker.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,16 @@ async def __get_loops(self):
255255
except Exception as e:
256256
logging.exception(f"{self.identity!r}: failed with unhandled exception:\n{e}")
257257

258-
await self._connector_external.send(WorkerDisconnectNotification.new_msg(self.identity))
258+
try:
259+
await self._connector_external.send(WorkerDisconnectNotification.new_msg(self.identity))
260+
except ymq.YMQException as e:
261+
262+
# this means that the scheduler shut down before we could send our notification
263+
# we don't consider this to be an error
264+
if e.code == ymq.ErrorCode.ConnectorSocketClosedByRemoteEnd:
265+
pass
266+
else:
267+
raise
259268

260269
self._connector_external.destroy()
261270
self._processor_manager.destroy("quit")
@@ -272,4 +281,5 @@ def __register_signal(self):
272281
self._loop.add_signal_handler(signal.SIGINT, self.__destroy)
273282

274283
def __destroy(self):
284+
print("DESTROYING WORKER!!!")
275285
self._task.cancel()

0 commit comments

Comments
 (0)