Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
b2ce833d
Commit
b2ce833d
authored
Jul 19, 2012
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
client: small optimizations
parent
990d6337
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
48 deletions
+13
-48
neo/client/handlers/__init__.py
neo/client/handlers/__init__.py
+2
-8
neo/client/handlers/master.py
neo/client/handlers/master.py
+1
-2
neo/lib/connection.py
neo/lib/connection.py
+10
-38
No files found.
neo/client/handlers/__init__.py
View file @
b2ce833d
...
...
@@ -25,14 +25,8 @@ class BaseHandler(EventHandler):
self
.
dispatcher
=
app
.
dispatcher
def
dispatch
(
self
,
conn
,
packet
,
kw
=
{}):
# Before calling superclass's dispatch method, lock the connection.
# This covers the case where handler sends a response to received
# packet.
conn
.
lock
()
try
:
assert
conn
.
_lock
.
_is_owned
()
super
(
BaseHandler
,
self
).
dispatch
(
conn
,
packet
,
kw
)
finally
:
conn
.
release
()
def
packetReceived
(
self
,
conn
,
packet
,
kw
=
{}):
"""Redirect all received packet to dispatcher thread."""
...
...
neo/client/handlers/master.py
View file @
b2ce833d
...
...
@@ -133,7 +133,6 @@ class PrimaryNotificationsHandler(BaseHandler):
if
node
and
node
.
isConnected
():
node
.
getConnection
().
close
()
class
PrimaryAnswersHandler
(
AnswerBaseHandler
):
""" Handle that process expected packets from the primary master """
...
...
@@ -141,7 +140,7 @@ class PrimaryAnswersHandler(AnswerBaseHandler):
self
.
app
.
setHandlerData
(
ttid
)
def
answerNewOIDs
(
self
,
conn
,
oid_list
):
self
.
app
.
new_oid_list
=
list
(
oid_list
)
self
.
app
.
new_oid_list
=
oid_list
def
answerTransactionFinished
(
self
,
conn
,
_
,
tid
):
self
.
app
.
setHandlerData
(
tid
)
...
...
neo/lib/connection.py
View file @
b2ce833d
...
...
@@ -728,36 +728,21 @@ class ServerConnection(Connection):
class
MTClientConnection
(
ClientConnection
):
"""A Multithread-safe version of ClientConnection."""
def
__metaclass__
(
name
,
base
,
d
):
for
k
in
(
'analyse'
,
'answer'
,
'checkTimeout'
,
'process'
,
'readable'
,
'writable'
):
d
[
k
]
=
lockCheckWrapper
(
getattr
(
base
[
0
],
k
).
im_func
)
return
type
(
name
,
base
,
d
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
# _lock is only here for lock debugging purposes. Do not use.
self
.
_lock
=
lock
=
RLock
()
self
.
acquire
=
lock
.
acquire
self
.
release
=
lock
.
release
self
.
lock
=
lock
.
acquire
self
.
unlock
=
lock
.
release
self
.
dispatcher
=
kwargs
.
pop
(
'dispatcher'
)
self
.
dispatcher
.
needPollThread
()
self
.
lock
()
try
:
with
lock
:
super
(
MTClientConnection
,
self
).
__init__
(
*
args
,
**
kwargs
)
finally
:
self
.
unlock
()
def
lock
(
self
,
blocking
=
1
):
return
self
.
acquire
(
blocking
=
blocking
)
def
unlock
(
self
):
self
.
release
()
@
lockCheckWrapper
def
writable
(
self
,
*
args
,
**
kw
):
return
super
(
MTClientConnection
,
self
).
writable
(
*
args
,
**
kw
)
@
lockCheckWrapper
def
readable
(
self
,
*
args
,
**
kw
):
return
super
(
MTClientConnection
,
self
).
readable
(
*
args
,
**
kw
)
@
lockCheckWrapper
def
analyse
(
self
,
*
args
,
**
kw
):
return
super
(
MTClientConnection
,
self
).
analyse
(
*
args
,
**
kw
)
def
notify
(
self
,
*
args
,
**
kw
):
self
.
lock
()
...
...
@@ -793,22 +778,9 @@ class MTClientConnection(ClientConnection):
finally
:
self
.
unlock
()
@
lockCheckWrapper
def
answer
(
self
,
*
args
,
**
kw
):
return
super
(
MTClientConnection
,
self
).
answer
(
*
args
,
**
kw
)
@
lockCheckWrapper
def
checkTimeout
(
self
,
*
args
,
**
kw
):
return
super
(
MTClientConnection
,
self
).
checkTimeout
(
*
args
,
**
kw
)
def
close
(
self
):
self
.
lock
()
try
:
super
(
MTClientConnection
,
self
).
close
()
finally
:
self
.
release
()
@
lockCheckWrapper
def
process
(
self
,
*
args
,
**
kw
):
return
super
(
MTClientConnection
,
self
).
process
(
*
args
,
**
kw
)
self
.
unlock
()
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