import sys
import praw
import signal
import linelib


def handler(x, y):
    pass

signal.signal(signal.SIGUSR1, handler)
signal.signal(signal.SIGALRM, handler)

ID = "reddit"

r = praw.Reddit(user_agent="unread message checker by /u/5225225")
auth = open(sys.argv[1])
username, password = auth.read().split(":")
auth.close()
r.login(username, password.strip())

while True:
    x = r.get_unread()
    x = list(x)
    if len(x) > 0:
        linelib.sendblock(ID, {"full_text": "[{}]".format(str(len(x))),
                               "color": "#ff4500"})
    linelib.sendPID(ID)
    linelib.waitsig(5)

@@ -360,42 +360,199 @@
 ))%0A%0A
-while True:%0A    x = r.get_unread()
+def sendline():%0A    try:%0A        x = r.get_unread(fetch=True)%0A    except requests.exceptions.HTTPError:%0A        #happens when reddit returns a 503. It should come back up soon.%0A        return
 %0A   
@@ -731,16 +731,16 @@
 PID(ID)%0A
-
     line
@@ -754,8 +754,36 @@
 tsig(5)%0A
+%0Awhile True:%0A    sendline()%0A

Fix bug, reddit.py crashes on 503 from reddit