mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-04 19:33:52 +00:00
Threads are now stopped correctly when someone stops the server
This commit is contained in:
1 parent
20461c9ddd
commit
3317d8d495
2 files changed
+15
-4
No files matched your search
@@ -53,12 +53,14 @@ class LiveDataReceiver(threading.Thread):
|
|||||||
|
|
||||||
# blocking call by updatecount setting
|
# blocking call by updatecount setting
|
||||||
conf.setParameters(dict(eventname=self.eventname, racename=self.racename, sinceupdate=self.updatecount))
|
conf.setParameters(dict(eventname=self.eventname, racename=self.racename, sinceupdate=self.updatecount))
|
||||||
conf.setLogging(True)
|
conf.setLogging(False)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# need to lock because other threads could overwrite information
|
# need to lock because other threads could overwrite information
|
||||||
with lock:
|
with lock:
|
||||||
updatecount = liveRaceInformation(conf)
|
updatecount = liveRaceInformation(conf)
|
||||||
|
print >>sys.stderr, '.',
|
||||||
|
sys.stderr.flush()
|
||||||
|
|
||||||
self.last_update = datetime.datetime.now()
|
self.last_update = datetime.datetime.now()
|
||||||
self.updatecount = updatecount
|
self.updatecount = updatecount
|
||||||
|
|||||||
@@ -165,9 +165,18 @@ def configureListener(context, request):
|
|||||||
del view.session['listener-conf']
|
del view.session['listener-conf']
|
||||||
view.session.save()
|
view.session.save()
|
||||||
|
|
||||||
key = hash('%s-%s-%s-%s' % (conf.host, conf.port, eventname, racename))
|
racenames = []
|
||||||
if threaded_listener.has_key(key):
|
if not racename:
|
||||||
threaded_listener[key].running = False
|
racenames = model.EventImpl.queryOneBy(name=eventname).races
|
||||||
|
else: racenames = [racename, ]
|
||||||
|
|
||||||
|
for rname in racenames:
|
||||||
|
key = hash('%s-%s-%s-%s' % (conf.host, conf.port, eventname, rname))
|
||||||
|
if threaded_listener.has_key(key):
|
||||||
|
threaded_listener[key].running = False
|
||||||
|
|
||||||
|
# remove this thread - will die later if still blocking
|
||||||
|
del threaded_listener[key]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
conf.trigger()
|
conf.trigger()
|
||||||
|
|||||||
Reference in new issue
Block a user