Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Carlos Ramos Carreño
neoppod
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
Hide 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):
...
@@ -25,14 +25,8 @@ class BaseHandler(EventHandler):
self
.
dispatcher
=
app
.
dispatcher
self
.
dispatcher
=
app
.
dispatcher
def
dispatch
(
self
,
conn
,
packet
,
kw
=
{}):
def
dispatch
(
self
,
conn
,
packet
,
kw
=
{}):
# Before calling superclass's dispatch method, lock the connection.
assert
conn
.
_lock
.
_is_owned
()
# This covers the case where handler sends a response to received
super
(
BaseHandler
,
self
).
dispatch
(
conn
,
packet
,
kw
)
# packet.
conn
.
lock
()
try
:
super
(
BaseHandler
,
self
).
dispatch
(
conn
,
packet
,
kw
)
finally
:
conn
.
release
()
def
packetReceived
(
self
,
conn
,
packet
,
kw
=
{}):
def
packetReceived
(
self
,
conn
,
packet
,
kw
=
{}):
"""Redirect all received packet to dispatcher thread."""
"""Redirect all received packet to dispatcher thread."""
...
...
neo/client/handlers/master.py
View file @
b2ce833d
...
@@ -133,7 +133,6 @@ class PrimaryNotificationsHandler(BaseHandler):
...
@@ -133,7 +133,6 @@ class PrimaryNotificationsHandler(BaseHandler):
if
node
and
node
.
isConnected
():
if
node
and
node
.
isConnected
():
node
.
getConnection
().
close
()
node
.
getConnection
().
close
()
class
PrimaryAnswersHandler
(
AnswerBaseHandler
):
class
PrimaryAnswersHandler
(
AnswerBaseHandler
):
""" Handle that process expected packets from the primary master """
""" Handle that process expected packets from the primary master """
...
@@ -141,7 +140,7 @@ class PrimaryAnswersHandler(AnswerBaseHandler):
...
@@ -141,7 +140,7 @@ class PrimaryAnswersHandler(AnswerBaseHandler):
self
.
app
.
setHandlerData
(
ttid
)
self
.
app
.
setHandlerData
(
ttid
)
def
answerNewOIDs
(
self
,
conn
,
oid_list
):
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
):
def
answerTransactionFinished
(
self
,
conn
,
_
,
tid
):
self
.
app
.
setHandlerData
(
tid
)
self
.
app
.
setHandlerData
(
tid
)
...
...
neo/lib/connection.py
View file @
b2ce833d
...
@@ -728,36 +728,21 @@ class ServerConnection(Connection):
...
@@ -728,36 +728,21 @@ class ServerConnection(Connection):
class
MTClientConnection
(
ClientConnection
):
class
MTClientConnection
(
ClientConnection
):
"""A Multithread-safe version of 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
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
# _lock is only here for lock debugging purposes. Do not use.
# _lock is only here for lock debugging purposes. Do not use.
self
.
_lock
=
lock
=
RLock
()
self
.
_lock
=
lock
=
RLock
()
self
.
acquire
=
lock
.
acquire
self
.
lock
=
lock
.
acquire
self
.
release
=
lock
.
release
self
.
unlock
=
lock
.
release
self
.
dispatcher
=
kwargs
.
pop
(
'dispatcher'
)
self
.
dispatcher
=
kwargs
.
pop
(
'dispatcher'
)
self
.
dispatcher
.
needPollThread
()
self
.
dispatcher
.
needPollThread
()
self
.
lock
()
with
lock
:
try
:
super
(
MTClientConnection
,
self
).
__init__
(
*
args
,
**
kwargs
)
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
):
def
notify
(
self
,
*
args
,
**
kw
):
self
.
lock
()
self
.
lock
()
...
@@ -793,22 +778,9 @@ class MTClientConnection(ClientConnection):
...
@@ -793,22 +778,9 @@ class MTClientConnection(ClientConnection):
finally
:
finally
:
self
.
unlock
()
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
):
def
close
(
self
):
self
.
lock
()
self
.
lock
()
try
:
try
:
super
(
MTClientConnection
,
self
).
close
()
super
(
MTClientConnection
,
self
).
close
()
finally
:
finally
:
self
.
release
()
self
.
unlock
()
@
lockCheckWrapper
def
process
(
self
,
*
args
,
**
kw
):
return
super
(
MTClientConnection
,
self
).
process
(
*
args
,
**
kw
)
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