Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ece428mp1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
azukor2
ece428mp1
Commits
da5e69f0
Commit
da5e69f0
authored
3 years ago
by
Jeffrey Zhang
Browse files
Options
Downloads
Patches
Plain Diff
Move client disconnect to seperate function
parent
3d4feade
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
TransactionDeliverer.py
+10
-17
10 additions, 17 deletions
TransactionDeliverer.py
with
10 additions
and
17 deletions
TransactionDeliverer.py
+
10
−
17
View file @
da5e69f0
...
...
@@ -75,10 +75,8 @@ class TransactionDeliverer:
proposed_priority
=
self
.
next_priority
self
.
next_priority
+=
1
pickled_proposed_priority_message
=
pickle
.
dumps
(
ProposedPriorityMessage
(
str
(
uuid4
()),
self
.
node_name
,
transaction_message
.
sender
,
transaction_message
.
transaction_ID
,
proposed_priority
)
)
try
:
...
...
@@ -88,15 +86,7 @@ class TransactionDeliverer:
)
except
BrokenPipeError
:
# Receiving node crashed
if
transaction_message
.
sender
in
self
.
client_sockets
:
sock
=
self
.
client_sockets
[
transaction_message
.
sender
]
del
self
.
client_sockets
[
transaction_message
.
sender
]
# Don't shutdown because this causes OSErrer?
#sock.shutdown(socket.SHUT_RDWR)
sock
.
close
()
# TODO think about how to deal with 4-5 second timeout
# reliable unicast
self
.
disconnect_node
(
transaction_message
.
sender
)
queue_item
=
_Transaction_Message_Queue_Item
(
proposed_priority
,
self
.
node_name
,
transaction_message
,
1
)
...
...
@@ -147,6 +137,14 @@ class TransactionDeliverer:
while
len
(
self
.
transactions_queue
)
>
0
and
self
.
transactions_queue
[
0
].
transaction_message
.
deliverable
:
transaction_to_process
=
self
.
transactions_queue
.
pop
(
0
)
self
.
transaction_executor
.
transaction
(
transaction_to_process
.
transaction_message
.
transaction
)
def
disconnect_node
(
self
,
client_name
):
if
client_name
in
self
.
client_sockets
:
sock
=
self
.
client_sockets
[
client_name
]
del
self
.
client_sockets
[
client_name
]
# Don't shutdown because this causes OSError?
#sock.shutdown(socket.SHUT_RDWR)
sock
.
close
()
def
multicast
(
self
,
client_names_messages
):
closed_connections
=
[]
...
...
@@ -163,12 +161,7 @@ class TransactionDeliverer:
closed_connections
.
append
(
cn
)
for
cn
in
closed_connections
:
if
cn
in
self
.
client_sockets
:
sock
=
self
.
client_sockets
[
cn
]
del
self
.
client_sockets
[
cn
]
# Don't shutdown because this causes OSError?
#sock.shutdown(socket.SHUT_RDWR)
sock
.
close
()
self
.
disconnect_node
(
cn
)
def
shutdown
(
self
):
for
sock
in
self
.
client_sockets
.
values
():
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment