mirror of
https://github.com/jlu5/PyLink.git
synced 2024-12-26 04:32:51 +01:00
main: shut down immediately when handle_events errors
This is to prevent accidents from frying a server's CPU. For example, a nick collision loop due to a desync!
This commit is contained in:
parent
6de30722b9
commit
3804e5e4f8
11
main.py
11
main.py
@ -7,6 +7,7 @@ import time
|
|||||||
import sys
|
import sys
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
import threading
|
import threading
|
||||||
|
import _thread
|
||||||
|
|
||||||
from log import log
|
from log import log
|
||||||
import conf
|
import conf
|
||||||
@ -100,7 +101,6 @@ class Irc():
|
|||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def disconnect(self):
|
def disconnect(self):
|
||||||
log.debug('(%s) Canceling pingTimer at %s due to disconnect() call', self.name, time.time())
|
log.debug('(%s) Canceling pingTimer at %s due to disconnect() call', self.name, time.time())
|
||||||
self.connected.clear()
|
self.connected.clear()
|
||||||
@ -129,7 +129,14 @@ class Irc():
|
|||||||
line = line.strip(b'\r')
|
line = line.strip(b'\r')
|
||||||
line = line.decode("utf-8")
|
line = line.decode("utf-8")
|
||||||
log.debug("(%s) <- %s", self.name, line)
|
log.debug("(%s) <- %s", self.name, line)
|
||||||
hook_args = self.proto.handle_events(self, line)
|
hook_args = None
|
||||||
|
try:
|
||||||
|
hook_args = self.proto.handle_events(self, line)
|
||||||
|
except Exception:
|
||||||
|
# We broke! Shutdown immediately.
|
||||||
|
log.exception('(%s) Caught error in handle_events, exiting!', self.name)
|
||||||
|
_thread.interrupt_main()
|
||||||
|
sys.exit(4)
|
||||||
# Only call our hooks if there's data to process. Handlers that support
|
# Only call our hooks if there's data to process. Handlers that support
|
||||||
# hooks will return a dict of parsed arguments, which can be passed on
|
# hooks will return a dict of parsed arguments, which can be passed on
|
||||||
# to plugins and the like. For example, the JOIN handler will return
|
# to plugins and the like. For example, the JOIN handler will return
|
||||||
|
Loading…
Reference in New Issue
Block a user