Skip to content

Commit

Permalink
Merge pull request #785 from ioanpocol/devel
Browse files Browse the repository at this point in the history
LB-1863 : Sometimes chained comment is being dublicated three times
  • Loading branch information
ioanpocol committed Jul 8, 2014
2 parents b66e1f5 + 7273a6f commit 2b3482d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
6 changes: 5 additions & 1 deletion plugins/livedesk-seo/livedesk/core/impl/seo_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from ally.cdm.spec import ICDM
from livedesk.api.blog import IBlogService
from superdesk.language.api.language import ILanguageService
from random import randint


# --------------------------------------------------------------------
Expand Down Expand Up @@ -95,6 +96,9 @@ def syncSeoBlogs(self):
'''
log.info('Start seo blog synchronization')

sleep_time = randint(0, 1000) * 0.001
time.sleep(sleep_time)

crtTime = datetime.datetime.now().replace(microsecond=0)

q = QBlogSeo(refreshActive=True)
Expand All @@ -118,7 +122,7 @@ def syncSeoBlogs(self):
assert isinstance(thread, Thread), 'Invalid thread %s' % thread
if thread.is_alive(): continue

if not self.blogSeoService.checkTimeout(blogSeo.Id, self.timeout_inteval * self.sync_interval): continue
if not self.blogSeoService.checkTimeout(blogSeo.Id, self.timeout_inteval * self.sync_interval): continue

self.syncThreads[key] = Thread(name='blog %d seo' % blogSeo.Blog,
target=self._syncSeoBlog, args=(blogSeo,))
Expand Down
14 changes: 10 additions & 4 deletions plugins/livedesk-sync/livedesk/core/impl/chained_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from .icon_content import ChainedIconContent
from superdesk.post.api.post import Post, IPostService
from uuid import uuid4
from random import randint

# --------------------------------------------------------------------

Expand Down Expand Up @@ -116,8 +117,12 @@ def syncChains():
def syncChains(self):
'''
Read all chained blog sync entries and sync with the corresponding blogs.
'''
'''
log.info('Start chained blog synchronization')

sleep_time = randint(0, 1000) * 0.001
time.sleep(sleep_time)

for blogSync in self.blogSyncService.getBySourceType(self.blog_provider_type):
assert isinstance(blogSync, BlogSync)
key = (blogSync.Blog, blogSync.Source)
Expand All @@ -128,10 +133,11 @@ def syncChains(self):
log.info('Chained thread for blog %d is alive', blogSync.Blog)
continue

if not self.blogSyncService.checkTimeout(blogSync.Id, self.timeout_inteval * self.sync_interval):
log.info('Chained thread for blog %d is already taken', blogSync.Blog)
continue

if not self.blogSyncService.checkTimeout(blogSync.Id, self.timeout_inteval * self.sync_interval):
log.info('Chained thread for blog %d is already taken', blogSync.Blog)
continue

self.syncThreads[key] = Thread(name='blog %d sync' % blogSync.Blog,
target=self._syncChain, args=(blogSync,))
self.syncThreads[key].daemon = True
Expand Down

0 comments on commit 2b3482d

Please sign in to comment.