Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cse550
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
Winston Jodjana
cse550
Commits
f944f6d7
Commit
f944f6d7
authored
2 years ago
by
Dixon Tirtayadi
Browse files
Options
Downloads
Patches
Plain Diff
Added main.py to run multiple paxoses
parent
157d44d0
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
assignment2/main.py
+29
-0
29 additions, 0 deletions
assignment2/main.py
assignment2/paxos.py
+6
-3
6 additions, 3 deletions
assignment2/paxos.py
with
35 additions
and
3 deletions
assignment2/main.py
0 → 100644
+
29
−
0
View file @
f944f6d7
from
audioop
import
add
import
subprocess
import
sys
import
signal
import
time
# Can spawn multiple paxos server
if
__name__
==
"
__main__
"
:
num_server
=
2
# If they pass in num_server as argument
if
len
(
sys
.
argv
)
==
2
:
num_server
=
int
(
sys
.
argv
[
1
])
HOST
,
PORT
=
"
localhost
"
,
9000
PORTSTART
=
9000
PORTEND
=
PORTSTART
+
num_server
-
1
processes
=
[]
try
:
for
i
in
range
(
num_server
):
proc
=
subprocess
.
Popen
([
"
python3
"
,
"
paxos.py
"
,
HOST
,
str
(
PORT
+
i
),
str
(
PORTSTART
),
str
(
PORTEND
)])
processes
.
append
(
proc
)
# Needed to sleep forever here until ctrl-c so we go into "finally" and kill processes
while
True
:
time
.
sleep
(
10
)
finally
:
for
proc
in
processes
:
# proc.send_signal(signal.SIGINT)
proc
.
kill
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
assignment2/paxos.py
+
6
−
3
View file @
f944f6d7
...
...
@@ -430,10 +430,13 @@ def send_msg(obj, dest_addr: Address):
if
__name__
==
"
__main__
"
:
HOST
,
PORT
=
sys
.
argv
[
1
],
int
(
sys
.
argv
[
2
])
# addresses = ((HOST, PORT),)
addresses
=
((
HOST
,
9000
),
(
HOST
,
9001
))
# Create the server, binding to localhost on port 9999
PORTSTART
,
PORTEND
=
int
(
sys
.
argv
[
3
]),
int
(
sys
.
argv
[
4
])
addresses
=
()
for
i
in
range
(
PORTSTART
,
PORTEND
+
1
):
addresses
+=
((
HOST
,
i
),)
# Create the server, binding to localhost on port 9999
server
=
Paxos
((
HOST
,
PORT
),
addresses
)
# Activate the server; this will keep running until you
# interrupt the program with Ctrl-C
...
...
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