Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
satella
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container 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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public
satella
Commits
4a380971
Commit
4a380971
authored
12 years ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
Termination option added
parent
b7393922
No related branches found
Branches containing commit
Tags
v2.14.16
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
network/selectloop.py
+3
-2
3 additions, 2 deletions
network/selectloop.py
threads/__init__.py
+9
-0
9 additions, 0 deletions
threads/__init__.py
with
12 additions
and
2 deletions
network/selectloop.py
+
3
−
2
View file @
4a380971
...
...
@@ -4,8 +4,9 @@ from Queue import Queue, Empty
from
satella.network.socket
import
BaseSocket
from
satella.network.exceptions
import
ConnectionFailedException
from
satella.threads
import
BaseThread
class
SelectLoop
(
Thread
):
class
SelectLoop
(
Base
Thread
):
"""
Thread that does a select loop.
In general, you are expected to subclass it and write methods corresponding to tasks. The loop works like this:
...
...
@@ -113,7 +114,7 @@ class SelectLoop(Thread):
def
run
(
self
):
self
.
on_startup
()
while
True
:
while
not
self
.
_terminating
:
self
.
loop
()
self
.
on_cleanup
()
for
sock
in
self
.
client_sockets
:
# Close surviving client sockets
...
...
This diff is collapsed.
Click to expand it.
threads/__init__.py
0 → 100644
+
9
−
0
View file @
4a380971
class
BaseThread
(
Thread
):
"""
Thread with internal termination flag
"""
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
_terminating
=
False
Thread
.
__init__
(
self
,
*
args
,
**
kwargs
)
def
terminate
(
self
):
"""
Sets internal termination flag
"""
self
.
_terminating
=
True
\ No newline at end of file
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