Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
wspy-monitor
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
wspy-monitor
Commits
5f5d23b8
Commit
5f5d23b8
authored
Sep 03, 2013
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made server more efficient
parent
0245def0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
17 deletions
+23
-17
server.py
server.py
+23
-17
No files found.
server.py
View file @
5f5d23b8
...
...
@@ -61,27 +61,13 @@ def stats():
if
__name__
==
'__main__'
:
server
=
websocket
(
extensions
=
[
WebkitDeflateFrame
()])
server
.
setsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_REUSEADDR
,
1
)
server
.
bind
((
''
,
8100
))
server
.
listen
(
5
)
clients
=
[]
def
connect
():
while
True
:
sock
,
address
=
server
.
accept
()
print
'Client connected at %s:%d'
%
address
clients
.
append
(
sock
)
t
=
Thread
(
target
=
connect
)
t
.
daemon
=
True
t
.
start
()
try
:
def
update
():
while
True
:
if
not
clients
:
time
.
sleep
(
6
)
continue
print
'stop thread'
break
status
=
Frame
(
OPCODE_TEXT
,
json
.
dumps
(
dict
(
stats
())))
...
...
@@ -93,6 +79,26 @@ if __name__ == '__main__':
clients
.
remove
(
client
)
time
.
sleep
(
1
)
server
=
websocket
(
extensions
=
[
WebkitDeflateFrame
()])
server
.
setsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_REUSEADDR
,
1
)
server
.
bind
((
''
,
8100
))
server
.
listen
(
5
)
t
=
Thread
(
target
=
update
)
t
.
daemon
=
True
try
:
while
True
:
sock
,
address
=
server
.
accept
()
print
'Client connected at %s:%d'
%
address
clients
.
append
(
sock
)
if
not
t
.
is_alive
():
print
'start thread'
t
=
Thread
(
target
=
update
)
t
.
daemon
=
True
t
.
start
()
except
KeyboardInterrupt
:
print
'Stopping server'
server
.
close
()
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