def clear_expired_sessions():
	for device in ("desktop", "mobile"):
		for sid in frappe.db.sql_list("""select sid from tabSessions
				where TIMEDIFF(NOW(), lastupdate) > TIME(%s)
				and device = %s""", (get_expiry_period(device), device)):
			delete_session(sid)
This function is meant to be called from scheduler
dataset/ETHPy150Open frappe/frappe/frappe/sessions.py/clear_expired_sessions