Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
agkyra
Commits
5ee67fb7
Commit
5ee67fb7
authored
Jun 04, 2015
by
Stavros Sachtouris
Committed by
Giorgos Korfiatis
Oct 19, 2015
Browse files
Store backend syncers in a thread-safe dict
parent
2ed93a9c
Changes
1
Hide whitespace changes
Inline
Side-by-side
agkyra/protocol.py
View file @
5ee67fb7
...
...
@@ -32,6 +32,7 @@ from agkyra.config import AgkyraConfig, AGKYRA_DIR
LOG
=
logging
.
getLogger
(
__name__
)
SYNCERS
=
utils
.
ThreadSafeDict
()
class
SessionHelper
(
object
):
...
...
@@ -193,10 +194,16 @@ class WebSocketProtocol(WebSocket):
exclude
=
None
)
status
=
dict
(
progress
=
0
,
synced
=
0
,
unsynced
=
0
,
paused
=
True
,
can_sync
=
False
)
file_syncer
=
None
cnf
=
AgkyraConfig
()
essentials
=
(
'url'
,
'token'
,
'container'
,
'directory'
)
@
property
def
syncer
(
self
):
with
SYNCERS
.
lock
()
as
d
:
for
sync_key
,
sync_obj
in
d
.
items
():
return
sync_obj
return
None
def
heartbeat
(
self
):
db
=
sqlite3
.
connect
(
self
.
session_db
)
while
True
:
...
...
@@ -354,12 +361,15 @@ class WebSocketProtocol(WebSocket):
**
kwargs
)
master
=
pithos_client
.
PithosFileClient
(
syncer_settings
)
slave
=
localfs_client
.
LocalfsFileClient
(
syncer_settings
)
self
.
syncer
=
syncer
.
FileSyncer
(
syncer_settings
,
master
,
slave
)
syncer
_
=
syncer
.
FileSyncer
(
syncer_settings
,
master
,
slave
)
self
.
syncer_settings
=
syncer_settings
self
.
syncer
.
initiate_probe
()
syncer
_
.
initiate_probe
()
except
setup
.
ClientError
:
self
.
syncer
=
None
syncer
_
=
None
raise
finally
:
with
SYNCERS
.
lock
()
as
d
:
d
[
0
]
=
syncer_
# Syncer-related methods
def
get_status
(
self
):
...
...
@@ -515,8 +525,6 @@ class WebSocketProtocol(WebSocket):
self
.
send_json
({
'%s'
%
ce
:
ce
.
status
,
'action'
:
action
})
return
except
Exception
as
e
:
from
traceback
import
print_stack
print_stack
(
e
)
self
.
send_json
({
'INTERNAL ERROR'
:
500
})
LOG
.
error
(
'EXCEPTION: %s'
%
e
)
self
.
terminate
()
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