Adding a session validity check in hopes of eventually expiring timed out connections.
This commit is contained in:
parent
0fc89247aa
commit
192ef521a2
3 changed files with 18 additions and 5 deletions
10
events.py
10
events.py
|
|
@ -1,15 +1,17 @@
|
||||||
|
import session_mgr
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Holds the events scheduled in scheduler.py.
|
Holds the events scheduled in scheduler.py.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
schedule = {
|
schedule = {
|
||||||
'event_example': 60,
|
'check_sessions': 60,
|
||||||
}
|
}
|
||||||
|
|
||||||
lastrun = {}
|
lastrun = {}
|
||||||
|
|
||||||
def event_example():
|
def check_sessions():
|
||||||
"""
|
"""
|
||||||
This is where the example event would be placed.
|
Check all of the connected sessions.
|
||||||
"""
|
"""
|
||||||
pass
|
session_mgr.check_all_sessions()
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ A really simple scheduler. We can probably get a lot fancier with this
|
||||||
in the future, but it'll do for now.
|
in the future, but it'll do for now.
|
||||||
|
|
||||||
ADDING AN EVENT:
|
ADDING AN EVENT:
|
||||||
* Add an entry to the 'schedule' dictionary.
|
* Add an entry to the 'schedule' dictionary in the 'events' file.
|
||||||
* Add the proper event_ function here.
|
* Add the proper event_ function here.
|
||||||
* Profit.
|
* Profit.
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,17 @@ def get_session_list():
|
||||||
"""
|
"""
|
||||||
return session_list
|
return session_list
|
||||||
|
|
||||||
|
def check_all_sessions():
|
||||||
|
"""
|
||||||
|
Check all currently connected sessions and see if any are dead.
|
||||||
|
"""
|
||||||
|
for sess in get_session_list():
|
||||||
|
if not sess.writable() or not sess.readable():
|
||||||
|
print 'Problematic Session:'
|
||||||
|
print 'Readable ', sess.readable()
|
||||||
|
print 'Writable ', sess.writable()
|
||||||
|
|
||||||
|
|
||||||
def remove_session(session):
|
def remove_session(session):
|
||||||
"""
|
"""
|
||||||
Removes a session from the session list.
|
Removes a session from the session list.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue