Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
7c9a7986
authored
Jan 23, 2013
by
x
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prevent updating firewall concurrently
parent
ea0e229a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
firewall/tasks.py
+9
-3
No files found.
firewall/tasks.py
View file @
7c9a7986
...
...
@@ -4,11 +4,9 @@ import os
import
time
from
firewall.fw
import
*
LOCK_EXPIRE
=
9
# Lock expires in 5 minutes
lock_id
=
"blabla"
def
reload_firewall_lock
():
acquire_lock
=
lambda
:
cache
.
add
(
lock_id
,
"true"
,
LOCK_EXPIRE
)
acquire_lock
=
lambda
:
cache
.
add
(
"reload_lock1"
,
"true"
,
9
)
if
acquire_lock
():
print
"megszereztem"
...
...
@@ -19,6 +17,13 @@ def reload_firewall_lock():
class
ReloadTask
(
Task
):
def
run
(
self
,
**
kwargs
):
acquire_lock
=
lambda
:
cache
.
add
(
"reload_lock1"
,
"true"
,
90
)
release_lock
=
lambda
:
cache
.
delete
(
"reload_lock1"
)
if
not
acquire_lock
():
print
"mar folyamatban van egy reload"
return
print
"indul"
time
.
sleep
(
10
)
...
...
@@ -40,3 +45,4 @@ class ReloadTask(Task):
print
"nem sikerult :("
print
"leall"
release_lock
()
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