Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
仰若水
frappe
Commits
92a67b7b
Commit
92a67b7b
authored
9 years ago
by
Anand Doshi
Browse files
Options
Download
Plain Diff
Merge branch 'hotfix'
parents
d43b93c4
31e6e95b
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
frappe/__init__.py
+1
-1
frappe/__init__.py
frappe/tasks.py
+14
-2
frappe/tasks.py
frappe/utils/file_lock.py
+3
-3
frappe/utils/file_lock.py
with
18 additions
and
6 deletions
+18
-6
frappe/__init__.py
View file @
92a67b7b
...
...
@@ -14,7 +14,7 @@ import os, importlib, inspect, logging, json
from
.exceptions
import
*
from
.utils.jinja
import
get_jenv
,
get_template
,
render_template
__version__
=
"6.27.2
3
"
__version__
=
"6.27.2
4
"
local
=
Local
()
...
...
This diff is collapsed.
Click to expand it.
frappe/tasks.py
View file @
92a67b7b
...
...
@@ -5,7 +5,7 @@ from __future__ import unicode_literals
import
frappe
from
frappe.utils.scheduler
import
enqueue_events
from
frappe.celery_app
import
get_celery
,
celery_task
,
task_logger
,
LONGJOBS_PREFIX
,
ASYNC_TASKS_PREFIX
from
frappe.utils
import
get_sites
from
frappe.utils
import
get_sites
,
touch_file
from
frappe.utils.error
import
make_error_snapshot
from
frappe.utils.file_lock
import
create_lock
,
delete_lock
from
frappe.handler
import
execute_cmd
...
...
@@ -17,6 +17,7 @@ import time
import
json
import
os
import
MySQLdb
from
frappe.utils.file_lock
import
check_lock
,
LockTimeoutError
@
celery_task
()
def
sync_queues
():
...
...
@@ -135,7 +136,17 @@ def scheduler_task(site, event, handler, now=False):
@
celery_task
()
def
enqueue_scheduler_events
():
for
site
in
get_sites
():
enqueue_events_for_site
.
delay
(
site
=
site
)
enqueue_lock
=
os
.
path
.
join
(
site
,
'locks'
,
'enqueue.lock'
)
try
:
if
check_lock
(
enqueue_lock
,
timeout
=
1800
):
continue
touch_file
(
enqueue_lock
)
enqueue_events_for_site
.
delay
(
site
=
site
)
except
LockTimeoutError
:
os
.
remove
(
enqueue_lock
)
@
celery_task
()
def
enqueue_events_for_site
(
site
):
...
...
@@ -149,6 +160,7 @@ def enqueue_events_for_site(site):
task_logger
.
error
(
'Exception in Enqueue Events for Site {0}'
.
format
(
site
))
raise
finally
:
delete_lock
(
'enqueue'
)
frappe
.
destroy
()
@
celery_task
()
...
...
This diff is collapsed.
Click to expand it.
frappe/utils/file_lock.py
View file @
92a67b7b
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt
# MIT License. See license.txt
from
__future__
import
unicode_literals
...
...
@@ -18,10 +18,10 @@ def create_lock(name):
else
:
return
False
def
check_lock
(
path
):
def
check_lock
(
path
,
timeout
=
600
):
if
not
os
.
path
.
exists
(
path
):
return
False
if
time
()
-
os
.
path
.
getmtime
(
path
)
>
600
:
if
time
()
-
os
.
path
.
getmtime
(
path
)
>
timeout
:
raise
LockTimeoutError
(
path
)
return
True
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help