nathanpjones / GaragePi

Overengineer your garage door with your Raspberry Pi!
MIT License
32 stars 14 forks source link

Telegram notifications fail #14

Open ocminer opened 3 years ago

ocminer commented 3 years ago

What's Wrong

Telegram Notifs fail

Environment Info

RPi Model:

RPI 4

OS Release:

Raspbian Stretch

Service Status:

active and running

Attach Logs

2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: [2021-01-05 02:02:57,092] INFO in telegram: Created TelegramNotification object Test notification from GaragePi 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: [2021-01-05 02:02:57,095] INFO in telegram: Triggering Telegram notification 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: Traceback (most recent call last): 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: File "/home/pi/garage_pi/venv/lib/python3.5/site-packages/flipflop.py", line 455, in run 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: protocol_status, app_status = self.server.handler(self) 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: File "/home/pi/garage_pi/venv/lib/python3.5/site-packages/flipflop.py", line 871, in handler 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: result = self.application(environ, start_response) 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: File "/home/pi/garage_pi/venv/lib/python3.5/site-packages/flask/app.py", line 2464, in call 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: return self.wsgi_app(environ, start_response) 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: File "/home/pi/garage_pi/venv/lib/python3.5/site-packages/flask/app.py", line 2450, in wsgi_app 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: response = self.handle_exception(e) 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: File "/home/pi/garage_pi/venv/lib/python3.5/site-packages/flask/app.py", line 1867, in handle_exception 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: reraise(exc_type, exc_value, tb) 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: File "/home/pi/garage_pi/venv/lib/python3.5/site-packages/flask/_compat.py", line 39, in reraise 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: raise value 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: File "/home/pi/garage_pi/venv/lib/python3.5/site-packages/flask/app.py", line 2447, in wsgi_app 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: response = self.full_dispatch_request() 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: File "/home/pi/garage_pi/venv/lib/python3.5/site-packages/flask/app.py", line 1952, in full_dispatch_request 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: rv = self.handle_user_exception(e) 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: File "/home/pi/garage_pi/venv/lib/python3.5/site-packages/flask/app.py", line 1821, in handle_user_exception 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: reraise(exc_type, exc_value, tb) 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: File "/home/pi/garage_pi/venv/lib/python3.5/site-packages/flask/_compat.py", line 39, in reraise 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: raise value 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: File "/home/pi/garage_pi/venv/lib/python3.5/site-packages/flask/app.py", line 1950, in full_dispatch_request 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: rv = self.dispatch_request() 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: File "/home/pi/garage_pi/venv/lib/python3.5/site-packages/flask/app.py", line 1936, in dispatch_request 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: return self.view_functionsrule.endpoint 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: File "/home/pi/garage_pi/webserver/garage.py", line 227, in test_telegram 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: event.trigger() 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: File "/home/pi/garage_pi/common/telegram.py", line 36, in trigger 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: apobj.notify(body=self.event_name) 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: File "/home/pi/garage_pi/venv/lib/python3.5/site-packages/apprise/Apprise.py", line 442, in notify 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: if not py3compat.asyncio.notify(coroutines, debug=self.debug): 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: File "/home/pi/garage_pi/venv/lib/python3.5/site-packages/apprise/py3compat/asyncio.py", line 79, in notify 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: loop = asyncio.get_event_loop() 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: File "/usr/lib/python3.5/asyncio/events.py", line 671, in get_event_loop 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: return get_event_loop_policy().get_event_loop() 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: File "/usr/lib/python3.5/asyncio/events.py", line 583, in get_event_loop 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: % threading.current_thread().name) 2021-01-05 02:02:57: (mod_fastcgi.c.2543) FastCGI-stderr: RuntimeError: There is no current event loop in thread 'Thread-3'.

nathanpjones commented 3 years ago

Hmm. @RealDudePerson, any suggestions here?

RealDudePerson commented 3 years ago

Shoot, as I mentioned I'm not super familiar with GitHub yet. I didn't intend to include the telegram notifications in the PR.

I was getting that same bug when using python 3.5 but the same code worked on python 3.7.

ocminer commented 3 years ago

Good reference would probably be this: https://stackoverflow.com/questions/48725890/runtimeerror-there-is-no-current-event-loop-in-thread-thread-1-multithreadi

Can't be something big, looks like there's simply no thread created at all