Python Forum
Is my pi sleeping or hanging up?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is my pi sleeping or hanging up?
#1
I was getting a warning on my mac terminal

Error:
WARNING:apscheduler.executors.default:Run time of job "timed_job (trigger: interval[1:00:00], next run at: 2016-11-19 05:31:35 CST)" was missed by 0:56:34.651017
Reply
#2
What is the context?
Reply
#3
Im running it from an ssh terminal on my mac. At first I thought my mac going to sleep was causing the problem but I dont think so because even if the mac goes to sleep, the rpi2 shouldnt. The script is scheduled to fetch data from the web every hour indefinitely. Can anyone tell me if its wrong to make the rpi2 run a scheduled job indefinitely?

Here is the code:

# class to hold read and write
#!/usr/bin/env python
import serial
import logging
import time, datetime
from firebase import firebase
from firebase_token_generator import create_token
from apscheduler.schedulers.blocking import BlockingScheduler

class AIHome:

	def __init__(self, onTime, offTime):
		self.onTime=onTime
		self.offTime=offTime
		self.updateInterval = 6
		self.webPush = False
		self.relayStatesA = []
		self.relayStatesD = {}
		logging.basicConfig()
		
		print('initting AIHome...scheduling job')
		sched = BlockingScheduler()
		@sched.scheduled_job('interval', hours=1)
		def timed_job():
			print('This job runs every 1 hrs. timed_job gets called or something else')
			self.fetchUpdate();		
		sched.configure()
		sched.start()
		 
	def fetchUpdate(self):
	    #Must separate credentials
		AIHome.authentication = firebase.FirebaseAuthentication('mykey', '[email protected]', extra={'id': 123})
		AIHome.firebase = firebase.FirebaseApplication('https://myapp.firebaseio.com/', AIHome.authentication)
		print AIHome.authentication.extra
		AIHome.user = AIHome.authentication.get_user()
		print AIHome.user.firebase_auth_token
		AIHome.results = AIHome.firebase.get('/Relays', None)#, {'print': 'pretty'})
		print AIHome.results		
		print AIHome.results['Relay1ON']
		print AIHome.results['Relay1OFF']
		self.relayToggle()
		
	def relayToggle(self):
		timestring = AIHome.results['Relay1ON']
		print timestring
		hours,minutes = timestring.split(":")
		print hours
		print minutes
		print(datetime.datetime.now())
		ref_time = datetime.datetime.combine(datetime.datetime.now(), datetime.time(int(hours), int(minutes)))
		if ref_time > datetime.datetime.now():
			print("ref_time>relay should be OFF")
		else:
			print("now>relay should be ON")

x = AIHome(1,2)
Thanks in advance!
Reply
#4
I edited the post title and code above to help describe the issue more clearly.
Reply
#5
So does apscheduler use the system scheduler? Or does your script continue to run forever, and just not do anything most of the time?
Reply
#6
What do you mean?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  python script is hanging while calling a procedure in database prasanthi417 4 442 Jan-17-2024, 02:33 PM
Last Post: deanhystad
  Hanging in View method learn_python 0 1,903 Feb-15-2019, 04:57 AM
Last Post: learn_python
  PyPDF2 Hanging When Trying to Open Corrupted PDF bmccollum 6 8,624 Nov-09-2018, 10:40 AM
Last Post: Larz60+
  pathlib hanging bluefrog 2 3,089 Sep-25-2018, 12:59 PM
Last Post: volcano63

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020